home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 1 / Macwelt DVD 1.toast / Web-Publishing / HTML-Editoren / Alpha ƒ / Tcl / Modes / metafontMode.tcl < prev    next >
Encoding:
Text File  |  2000-11-11  |  101.6 KB  |  3,137 lines

  1. ## -*-Tcl-*- (install) (nowrap)
  2. #   This is Metafont Mode for Alpha 7.2 or later. 
  3. #   If you still have Alpha 7.0 or 7.1, get Metafont Mode version 1.0 (and update soon).
  4. # Metafont Mode is a mode for the text editor Alpha: it is designed  to  make
  5. # writing, processing and testing  of  Metafont  source  files  much  easier.
  6. # Metafont is the programming language written, as a  companion  to  TeX,  by
  7. # Donald Knuth in order to create characters, fonts, font families (and  many
  8. # others things). Once Metafont mode is installed, the opening of a  Metafont
  9. # source file (i-e with extension .mf) invokes a new menu (called Metafont !)
  10. # in the menu bar with the following features :
  11. # -  easy insertion of all the basic Metafont commands (with electric stops)
  12. # -  syntax coloring
  13. # -  file marking
  14. # -  capacity to process a source file from within Alpha with various  flags,
  15. # printer modes, input base files
  16. # -  editing the log file
  17. # - capacity to make the pk file, to make the dvi from the generic  font,  to
  18. # view the dvi, to convert dvi to ps from within Alpha
  19. # -  capacity to make and to edit the property list of a font
  20. # -  capacity to process an entire folder of mf source files
  21. # -  ready to use template for a new font
  22. # -  key bindings to choose the processing mode, process files etc.
  23. # -  advanced keywords completion
  24. # -  command clicking on a word leads to its definition
  25. # -  option clicking on the title bar of a window brings a list  of  .mf  and
  26. # .log files at the same level or in a selected folder  and  allows  to  edit
  27. # them.
  28. # As of this release, both <CMacTeX Metafont> and <OzMetafont> are  supported
  29. # (together with their respective gftopk, gftodvi, dvipreviewer and tftopl).
  30. #      -->  Click here on <Metafont Help> to read the instructions or open 
  31. #      this file from the Help menu.
  32.  ## Author :  Bernard Desgraupes  
  33.  ## e-mail:   <berdesg@easynet.fr>
  34.  ## www:  <http://perso.easynet.fr/~berdesg/metafont.html>
  35.  ## Created : 03/28/99
  36.  ## Last modification : 23 juin 2000 - 22:09:55
  37. ##
  38. ##  Copyright (c) Bernard Desgraupes 1999, 2000
  39.  #
  40.  # 
  41. ## 
  42.  # This program is free software; you can redistribute it  and/or  modify
  43.  # it under the terms of the GNU General Public License as  published  by
  44.  # the Free Software Foundation; either version 2 of the License, or  any
  45.  # later version :
  46.  # <http://www.gnu.org/copyleft/gpl.html> 
  47.  # This program is distributed in the hope that it will  be  useful,  but
  48.  # WITHOUT ANY WARRANTY; without even    the    implied    warranty    of
  49.  # MERCHANTABILITY or FITNESS FOR  A  PARTICULAR  PURPOSE.  See  the  GNU
  50.  # General Public License for more details.
  51.  # You should have received a copy of  the  GNU  General  Public  License
  52.  # along with this program; if not, write to the FreeSoftware Foundation,
  53.  # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  54.  ##
  55.  
  56.  
  57. alpha::mode Mf 1.2.31 mfMenu {*.mf *.plf *.vpl} mfMenu {
  58.     alpha::package require AlphaTcl 7.2
  59.     addMenu mfMenu "Metafont"
  60. } maintainer {
  61.     "Bernard Desgraupes" <berdesg@easynet.fr> <http://perso.easynet.fr/~berdesg/metafont.html> 
  62. } uninstall this-file help {file "Metafont Help"}
  63.  
  64.  
  65. namespace eval Mf {}
  66.  
  67. #######   Preferences  #############
  68.  
  69. newPref f wordWrap {0} Mf
  70. # Set this flag if you want your source file to be marked automatically when it is opened.
  71. newPref f autoMark {1} Mf
  72. # Set this flag if you want the tab key to behave electrically (to jump from a bullet
  73. # to the next one in templates for instance).
  74. newPref f electricTab {1} Mf
  75. # Metafont particular processing option.
  76. # Metafont particular processing option.
  77. newPref f gfcorners 0 Mf  Mf::shadowMf
  78. # Metafont particular processing option.
  79. newPref f imagerules 0 Mf   Mf::shadowMf
  80. # Metafont particular processing option.
  81. newPref f nodisplays 0 Mf   Mf::shadowMf
  82. # Metafont particular processing option.
  83. newPref f notransforms 0 Mf   Mf::shadowMf
  84. # Metafont particular processing option.
  85. newPref f screenstrokes 0 Mf   Mf::shadowMf
  86. # Metafont particular processing option.
  87. newPref f screenchars 0 Mf   Mf::shadowMf
  88. # Set this flag to build a list of all source files on your installation.
  89. # You will have to set the path to the top folder with the PathToSourceFile
  90. # preference. Folders can be nested : use the NestingDepth pref to say how deep.
  91. newPref f buildSourceFiles 0 Mf Mf::shadowList
  92. # If this flag is set all the output will go in the MFworkFolder
  93. # instead of going in the same folder as the source file. 
  94. # This feature works only with CMacTeX Metafont.
  95. newPref f useWorkFold 0 Mf
  96. # Name of the printer mode for Metafont : for instance cx at 300dpi, 
  97. # canonex at 600dpi etc. Default is canonex.
  98. newPref v mfModeForPrinter canonex Mf
  99. # Prefix for comments in Metafont source files.
  100. newPref v prefixString {% } Mf
  101. # Regular expression used in the Functions pop-up menu 
  102. # (above the M pop-up menu, top right of the current window).
  103. newPref v funcExpr {^(def|vardef|primarydef|secondarydef|tertiarydef) [^\(=@;\r]+} Mf
  104. # Metafont mode's notion of what is a word.
  105. newPref v wordBreak {[_\w]+} Mf
  106. newPref v wordBreakPreface {[^_\w]} Mf
  107. # Here we allow the user to customize the denomination of the beginchar macro.
  108. newPref v userBeginchar beginchar Mf
  109. # To customize the denomination of the endchar macro.
  110. newPref v userEndchar endchar Mf
  111. # Default colo(u)rs for the keywords
  112. newPref v commentColor red Mf
  113. newPref v keywordColor blue Mf
  114. newPref v stringColor green Mf
  115. newPref v primitivesColor magenta Mf
  116. # Metafont menu, when used for the first time, must determine
  117. # which Metafont application is installed. A proc will do
  118. # that automatically, but this choice can be overriden afterwards
  119. # in the mode specific prefs.
  120. newPref v mfAppSig {} Mf Mf::rebuildOtherfiles
  121. # Folder where Metafont sends its output to.
  122. newPref folder MfworkFolder $HOME Mf
  123. # Where is the file modes.mf defining the parameters' values for 
  124. # all possible Metafont modes ?
  125. newPref file pathToModesMfFile {} Mf
  126. # Where is the file plain.mf defining the Metafont's basic macros ?
  127. newPref file pathToPlainMfFile {} Mf
  128. # Set here the location of a folder containing mf files (for instance the top one on your
  129. # installation but not necessarily). It may contain subfolders : choose the depth with 
  130. # the nestingDepth pref.
  131. newPref file pathToSourceFolder {} Mf Mf::shadowList
  132. # Choose the depth of subfolders nesting in the main source folder.
  133. newPref v nestingDepth {3} Mf Mf::shadowList
  134. # To insert your name in the preambule of a new font template.
  135. newPref v myName {} Mf
  136. # To insert your e-mail in the preambule of a new font template.
  137. newPref v myEMail {} Mf
  138. # To insert your home page in the preambule of a new font template.
  139. newPref url myWebPage {http://} Mf
  140.  
  141.  
  142. #######   Initialization of some variables  #############
  143. set MFtailfilename [file tail [win::Current]]
  144. set chosenMode proof
  145. set mag 1
  146. set vars [list gfcorners imagerules nodisplays notransforms screenchars screenstrokes \
  147.       magstep magflag magstepflag Mfbasefileflag mfset]
  148. foreach v $vars { set $v 0 }
  149. set vars [list prefixtfm prefixplf prefixgf prefixdvi prefixlog prefixrmall fromfolder]
  150. foreach v $vars { set $v "(" }
  151. set mfwd $HOME
  152. set MFoutputfolder $MfmodeVars(MfworkFolder)
  153. set Mfbasefile ""
  154. set tfmfile ""
  155. set MFcurrentdir ""
  156. set MFfilenames ""
  157. # To prefix subfolders names in the Source Files menu:
  158. set mfsymb "•"
  159. set Mf::commentCharacters(General) "%"
  160. set Mf::commentCharacters(Paragraph) [list "%% " " %%" " % "]
  161. set Mf::commentCharacters(Box) [list "%" 1 "%" 1 "%" 3]
  162.  
  163. proc mfMenu {} {}
  164.  
  165. hook::register activateHook Mf::rebuildOtherfiles Mf
  166.  
  167. #############  Select the Metafont application when using this mode for the first time #############
  168.  
  169. if {$MfmodeVars(mfAppSig)== ""} {
  170.     set mfsignlist [list "CMacTex mf" "OzMetafont"]
  171.     set sig [listpick -p "Select your Metafont application"  $mfsignlist]
  172.     switch $sig {
  173.         "CMacTex mf" {set mfAppSig "CMT3"}
  174.         "OzMetafont" {set mfAppSig "OzMF"}
  175.         }
  176.     removeArrDef MfmodeVars mfAppSig
  177.     set MfmodeVars(mfAppSig) $mfAppSig
  178.      addArrDef MfmodeVars mfAppSig $mfAppSig
  179. }
  180.  
  181. # # A proc to search a directory 'dir' and all its subdirectories looking for files
  182. # # with extension 'mf'.
  183. proc Mf::listSrcInDir {dir ext} {
  184.     global MFfilenames
  185.     set itemslist($dir) [glob -nocomplain -dir $dir *]
  186.     foreach f $itemslist($dir) {
  187.     if {[file isfile $f] && [file extension [file tail $f]]==".mf"} {
  188.         set f [file tail $f]
  189.         regsub "\(\[^\\.\]\)\.mf" $f "\\1" f
  190.         lappend MFfilenames " $f"
  191.     } elseif {[file isdirectory $f]} {
  192.         Mf::listSrcInDir $f mf
  193.     }
  194.     }
  195. }
  196.  
  197.  
  198. ##############################################
  199. #                                            #
  200. #    Metafont Menus Building Procs           #
  201. #                                            #
  202. ##############################################
  203.  
  204. menu::buildProc mfMenu menu::buildMf
  205. menu::buildProc otherFiles menu::buildotherFiles
  206. menu::buildProc removeFiles menu::buildremoveFiles
  207. menu::buildProc sourceFiles menu::buildsourceFiles
  208.  
  209. proc menu::buildMf {} {
  210.     global mfMenu otherFiles MFtailfilename
  211.     set ma {
  212.     "switchToMetafont"
  213.     "(-"
  214.     "/R<UrunTheBuffer"
  215.     "saveAndRun"
  216.     "<E<SrunAFile"
  217.     "<S<IrunAFolder"
  218.     "<S<BrunCurrentFolder"
  219.     "(-"
  220. {Menu -n "metafontMode" -p Mf::choosemodeProc {
  221.     "proof"
  222.     "smoke"
  223.     "localfont"
  224.     "userDefined"
  225.     }
  226. }
  227. {Menu -n "processingOptions" -p Mf::processingoptProc {
  228.     "mag..."
  229.     "magstep..."
  230.     "baseFile..."
  231.     "(-"
  232.     "gfcorners"
  233.     "imagerules"
  234.     "nodisplays"
  235.     "notransforms"
  236.     "screenchars"
  237.     "screenstrokes"
  238.     "(-"
  239.     "clearAllOptions"
  240.     }
  241. }
  242.     "(-"
  243. }
  244.     lappend ma [list Menu -n sourceFiles {}]
  245.     lappend ma [list Menu -n otherFiles {}]
  246.     append ma {
  247.       "(-"
  248.       "newFontTemplate"
  249.       "(-"
  250. {Menu -n "variables" -p Mf::variablesProc {    
  251.     " boolean"
  252.     " numeric"
  253.     " pair"
  254.     " path"
  255.     " pen"
  256.     " picture"
  257.     " string"
  258.     " transform"
  259.     " newinternal"
  260.     }
  261. }
  262. {Menu -n "boolean" -p Mf::booleanProc {    
  263.     " charexists"
  264.     " cycle"
  265.     " false"
  266.     " known"
  267.     " true"
  268.     " unknown"
  269.     }
  270. }
  271. {Menu -n "functions" -p Mf::functionsProc {    
  272.     " angle"
  273.     " ceilling"
  274.     " floor"
  275.     " cosd"
  276.     " sind"
  277.     " mexp"
  278.     " mlog"
  279.     " sqrt"
  280.     "(-"
  281.     " round"
  282.     " hround"
  283.     " vround"
  284.     " dotprod"
  285.     "(-"
  286.     " eps"
  287.     " epsilon"
  288.     " infinity"
  289.     "(-"
  290.     " solve"
  291.     " tolerance"
  292.     "(-"
  293.     " normaldeviate"
  294.     " randomseed"
  295.     " uniformdeviate"
  296.     " whatever"
  297.     }
  298. }
  299. {Menu -n "positioning" -p Mf::positioningProc {    
  300.     " direction"
  301.     " directionpoint"
  302.     " directiontime"
  303.     " penoffset"
  304.     " point…of"
  305.     " precontrol…of"
  306.     " postcontrol…of"
  307.     " intersectionpoint"
  308.     " intersectiontimes"
  309.     "(-"
  310.     " good.bot"
  311.     " good.lft"
  312.     " good.rt"
  313.     " good.top"
  314.     " good.x"
  315.     " good.y"
  316.     "(-"
  317.     " xpart"
  318.     " xxpart"
  319.     " xypart"
  320.     " ypart"
  321.     " yxpart"
  322.     " yypart"
  323.     " clearxy"
  324.     }
  325. }
  326. {Menu -n "paths" -p Mf::pathsProc {    
  327.     " penstroke"
  328.     " build…penstroke"
  329.     "(-"
  330.     " flex"
  331.     " fullcircle"
  332.     " halfcircle"
  333.     " quartercircle"
  334.     " superellipse"
  335.     " unitsquare"
  336.     "(-"
  337.     " makepath"
  338.     " interpath"
  339.     " subpath"
  340.     " tensepath"
  341.     " counterclockwise"
  342.     " reverse"
  343.     "(-"
  344.     " turningnumber"
  345.     }
  346. }
  347. {Menu -n "pens" -p Mf::pensProc {    
  348.     " <E<Spencircle"
  349.     " <S<Opickup…pencircle"
  350.     " <S<Ipencircle…scaled"
  351.     " <S<I<Opickup…pencircle…scaled"
  352.     " <E<Spensquare"
  353.     " <S<Opickup…pensquare"
  354.     " <S<Ipensquare…scaled"
  355.     " <S<I<Opickup…pensquare…scaled"
  356.     " penrazor"
  357.     " penspeck"
  358.     "(-"
  359.     " penpos"
  360.     "(-"
  361.     " clear_pen_memory"
  362.     " clearpen"
  363.     " currentpen"
  364.     " makepen"
  365.     " nullpen"
  366.     " savepen"
  367.     "(-"
  368.     " pen_bot"
  369.     " pen_lft"
  370.     " pen_rt"
  371.     " pen_top"
  372.     " pickup"
  373.     }
  374. }
  375. {Menu -n "pictures" -p Mf::picturesProc {    
  376.     " blankpicture"
  377.     " clearit"
  378.     " currentpicture"
  379.     " nullpicture"
  380.     "(-"
  381.     " totalweight"
  382.     " unitpixel"
  383.     }
  384. }
  385. {Menu -n "transformations" -p Mf::transformationsProc {    
  386.     " currenttransform"
  387.     " identity"
  388.     " inverse"
  389.     " reflectedabout"
  390.     " rotated"
  391.     " rotatedaround"
  392.     " scaled"
  393.     " shifted"
  394.     " slanted"
  395.     " transformed"
  396.     " xscaled"
  397.     " yscaled"
  398.     " zscaled"
  399.     }
  400. }
  401. {Menu -n "definitions" -p Mf::definitionsProc {    
  402.     " def…enddef"
  403.     " suffix"
  404.     " expr"
  405.     " text"
  406.     " primarydef…enddef"
  407.     " secondarydef…enddef"
  408.     " tertiarydef…enddef"
  409.     " vardef…enddef"
  410.     " begingroup…endgroup"
  411.     }
  412. }
  413. {Menu -n "conditions" -p Mf::conditionsProc {    
  414.     " for…endfor"
  415.     " forever…endfor"
  416.     " forsuffixes…endfor"
  417.     " if…fi"
  418.     " if…elseif…else…fi"
  419.     " downto"
  420.     " upto"
  421.     " step…until"
  422.     " exitif"
  423.     " exitunless"
  424.     }
  425. }
  426. {Menu -n "drawing" -p Mf::drawingProc {    
  427.     " <Saddto…also"
  428.     " <S<Iaddto…currentpicture"
  429.     " <E<Saddto…contour"
  430.     " <S<Iaddto…contour…withpen"
  431.     " <S<Oaddto…contour…withweight"
  432.     " <E<Saddto…doublepath"
  433.     " <S<Iaddto…doublepath…withpen"
  434.     " <S<Oaddto…doublepath…withweight"
  435.     " <E<Scull…dropping"
  436.     " <S<Ocull…dropping…withweight"
  437.     " <E<Scull…keeping"
  438.     " <S<Ocull…keeping…withweight"
  439.     " cullit"
  440.     "(-"
  441.     " <E<Sdraw"
  442.     " <S<Iundraw"
  443.     " <E<Sdrawdot"
  444.     " <S<Iundrawdot"
  445.     " <E<Sfill"
  446.     " <S<Iunfill"
  447.     " <E<Sfilldraw"
  448.     " <S<Iunfilldraw"
  449.     "(-"
  450.     " cutdraw"
  451.     " cutoff"
  452.     " erase"
  453.     }
  454. }
  455. {Menu -n "characters" -p Mf::charactersProc {    
  456.     " beginchar…endchar"
  457.     " extra_beginchar"
  458.     " extra_endchar"
  459.     }
  460. }
  461. {Menu -n "modesDefinitions" -p Mf::unitsProc {    
  462.     " blacker"
  463.     " fillin"
  464.     " o_correction"
  465.     " fix_units"
  466.     " mode_setup"
  467.     " pixels_per_inchs"
  468.     " aspect_ratio"
  469.     }
  470. }
  471. {Menu -n "pixellisation" -p Mf::pixellisationProc {    
  472.     " define_pixels"
  473.     " define_blacker_pixels"
  474.     " define_good_x_pixels"
  475.     " define_good_y_pixels"
  476.     " define_corrected_pixels"
  477.     " define_horizontal_corrected_pixels"
  478.     " define_whole_pixels"
  479.     " define_whole_blacker_pixels"
  480.     " define_whole_vertical_pixels"
  481.     " define_whole_vertical_blacker_pixels"
  482.     }
  483. }
  484. {Menu -n "fontInternals" -p Mf::fontInternalsProc {    
  485.     " charlist"
  486.     " extensible"
  487.     " font_coding_scheme"
  488.     " font_extra_space"
  489.     " font_identifier"
  490.     " font_normal_shrink"
  491.     " font_normal_space"
  492.     " font_normal_stretch"
  493.     " font_quad"
  494.     " font_size"
  495.     " font_slant"
  496.     " font_x_height"
  497.     " fontdimen"
  498.     " headerbytes"
  499.     " ligtable"
  500.     " kern"
  501.     }
  502. }
  503. {Menu -n "strings" -p Mf::stringsProc {    
  504.     " ditto"
  505.     " jobname"
  506.     " readstring"
  507.     " substring"
  508.     }
  509. }
  510. {Menu -n "displaying" -p Mf::displayingProc {    
  511.     " currentwindow"
  512.     " display…inwindow"
  513.     " openwindow…from…to…at"
  514.     " screen_cols"
  515.     " screen_rows"
  516.     " screenrule"
  517.     }
  518. }
  519. {Menu -n "output" -p Mf::outputProc {    
  520.     " openit"
  521.     " shipit"
  522.     " showit"
  523.     "(-"
  524.     " labels"
  525.     " labels…range…thru"
  526.     " penlabels"
  527.     " makelabel"
  528.     " makegrid..."
  529.     "(-"
  530.     " proofoffset"
  531.     " proofrule"
  532.     " proofrulethickness"
  533.     "(-"
  534.     " grayfont"
  535.     " labelfont"
  536.     " slantfont"
  537.     " titlefont"
  538.     }
  539. }
  540. {Menu -n "debugging" -p Mf::debuggingProc {    
  541.     " errhelp"
  542.     " errmessage"
  543.     " message"
  544.     " stop"
  545.     "(-"
  546.     " show"
  547.     " showdependencies"
  548.     " showstats"
  549.     " showtoken"
  550.     " showvariable"
  551.     "(-"
  552.     " loggingall"
  553.     " tracingall"
  554.     " tracingnone"
  555.     "(-"
  556.     " batchmode"
  557.     " errorstopmode"
  558.     " nonstopmode"
  559.     " scrollmode"
  560.     }
  561. }
  562. {Menu -n "misc" -p Mf::miscProc {    
  563.     " capsule_def"
  564.     " expandafter"
  565.     " gobble"
  566.     " gobbled"
  567.     " interact"
  568.     " numtok"
  569.     " scantokens"
  570.     " special"
  571.     " numspecial"
  572.     }
  573. }
  574. {Menu -n "internalVariables" -p Mf::varintProc {    
  575.     " autorounding"
  576.     " designsize"
  577.     " fontmaking"
  578.     " granularity"
  579.     " pausing"
  580.     " proofing"
  581.     " showstopping"
  582.     " smoothing"
  583.     "(-"
  584.     " charcode"
  585.     " chardp"
  586.     " chardx"
  587.     " chardy"
  588.     " charext"
  589.     " charht"
  590.     " charic"
  591.     " charwd"
  592.     "(-"
  593.     " hppp"
  594.     " vppp"
  595.     "(-"
  596.     " xoffset"
  597.     " yoffset"
  598.     "(-"
  599.     " day"
  600.     " month"
  601.     " year"
  602.     " time"
  603.     "(-"
  604.     " tracingcapsules"
  605.     " tracingchoices"
  606.     " tracingcommands"
  607.     " tracingedges"
  608.     " tracingequations"
  609.     " tracingmacros"
  610.     " tracingonline"
  611.     " tracingoutput"
  612.     " tracingpens"
  613.     " tracingrestores"
  614.     " tracingspecs"
  615.     " tracingstats"
  616.     " tracingtitles"
  617.     " turningcheck"
  618.     " warningcheck"
  619.     }
  620. }
  621. }
  622.     return [list build $ma Mf::menuProc {sourceFiles otherFiles} $mfMenu]
  623. }
  624.  
  625. proc menu::buildotherFiles {} {
  626.     global MFfullfilename MFdirfilename MFtailfilename #
  627.     global MFbasefilename MFextfilename MFoutputfolder #
  628.     global MfmodeVars mfAppSig MfworkFolder fromfolder MFcurrentdir
  629.     global prefixtfm prefixdvi prefixplf prefixgf prefixlog prefixrmall 
  630.     
  631.     set MFbasefilename [file rootname [file tail [win::Current]]]
  632.     set ma "${prefixgf}convertGfToPk"
  633.     if {$MfmodeVars(mfAppSig) == "CMT3"} {
  634.     lappend ma "<E${prefixgf}convertGfToDvi"
  635.     }
  636.     lappend ma "<E${prefixdvi}view $MFbasefilename.dvi"
  637.     if {$MfmodeVars(mfAppSig) == "CMT3"} {
  638.     lappend ma "<E${prefixdvi}convert $MFbasefilename.dvi to ps"
  639.     }
  640.     lappend ma "<E<S${prefixtfm}convert $MFbasefilename.tfm to pl"
  641.     lappend ma "<E<StfmToPl..."
  642.     lappend ma "<S<ItfmToPlAFolder..."
  643.     lappend ma "<S<BtfmToPlCurrentFolder"
  644.     lappend ma "<E<SvpToVf..."
  645.     lappend ma "<S<IvpToVfAFolder..."
  646.     lappend ma "<S<BvpToVfCurrentFolder"
  647.     lappend ma "(-"
  648.     lappend ma "<S${prefixlog}open $MFbasefilename.log"
  649.     lappend ma "<S<I${fromfolder}openAllLogFiles"
  650.     lappend ma "<E<S${prefixplf}openPropertyList" 
  651.     lappend ma "<S<I${fromfolder}openAllPropertyLists" 
  652.     foreach i {"(-" "open modes.mf" "open plain.mf" "(-" "metafontBindings"} {
  653.     lappend ma $i
  654.         }
  655.     lappend ma "chooseAFolder..."
  656.     lappend ma [list Menu -n removeFiles {}]
  657.     lappend ma  "(-"
  658. if {$MFcurrentdir != ""} {
  659.     lappend ma  [menu::itemWithIcon "currentFolderIs:" 83] 
  660.     lappend ma " [file tail $MFcurrentdir]"
  661.     } else {
  662.         lappend ma [menu::itemWithIcon "noFolderSelected" 82] 
  663. }
  664.       return [list build $ma Mf::otherfilesProc {removeFiles} ]
  665. }
  666.  
  667. proc menu::buildremoveFiles {} {
  668.     global MFcurrentdir prefixrmall 
  669.     set ma "${prefixrmall}allLogFiles"
  670.     lappend ma "${prefixrmall}allGfFiles"
  671.     lappend ma "${prefixrmall}allPkFiles"
  672.     lappend ma "${prefixrmall}allDviFiles"
  673.     lappend ma "${prefixrmall}allTfmFiles"
  674.     lappend ma "${prefixrmall}allVfFiles"
  675.     lappend ma "${prefixrmall}allPlFiles"
  676.     lappend ma "${prefixrmall}allVplFiles"
  677.     lappend ma "(-"
  678.     lappend ma "${prefixrmall}allOfThem"
  679.  
  680.     return [list build $ma Mf::removefilesProc ]
  681. }    
  682.  
  683. proc menu::buildsourceFiles {} {
  684.     global mfSubmenuItems MfmodeVars pathToSourceFolder buildSourceFiles
  685.     global nestingDepth MFfilenames reste mfsymb
  686.     set defaultSubmenuItems "Menu -m -n sourceFiles -p Mf::sourceFilesProc \{{Rebuild Source List} {(-}\}"
  687.     if {$MfmodeVars(buildSourceFiles)} {
  688.     if {$MfmodeVars(pathToSourceFolder) == ""} {
  689.         catch {get_directory -p "Locate the mf sources folder."} mfdir
  690.         if {$mfdir != ""} {
  691.         removeArrDef MfmodeVars pathToSourceFolder
  692.         set MfmodeVars(pathToSourceFolder) $mfdir
  693.         addArrDef MfmodeVars pathToSourceFolder $mfdir
  694.         } else {
  695.         set MFfilenames {}
  696.         return $defaultSubmenuItems
  697.         }        
  698.     }    
  699.     if { ![info exists mfSubmenuItems] || $mfSubmenuItems == "" } {
  700.         global mfPaths
  701.         set reste ""
  702.         set mfSubmenuItems \
  703.           [menu::buildHierarchy $MfmodeVars(pathToSourceFolder) "sourceFiles" \
  704.           Mf::sourceFilesProc mfPaths ".mf" $MfmodeVars(nestingDepth)]
  705.         regexp {^Menu -m -n sourceFiles -p Mf::sourceFilesProc \{(.*)$} $mfSubmenuItems "" reste
  706.         regsub -all "(Menu -m -n\[ \]+(\{)?)" $reste "\\1$mfsymb" reste
  707.         set mfSubmenuItems "Menu -m -n sourceFiles -p Mf::sourceFilesProc \{{Rebuild Source List} {(-} $reste"
  708.     }
  709.     } else {
  710.     set mfSubmenuItems $defaultSubmenuItems
  711.     }
  712.     if {$MfmodeVars(pathToSourceFolder) == ""} {
  713.     Mf::listSrcInDir [file dirname [win::Current]] mf
  714.     } else {
  715.     Mf::listSrcInDir $MfmodeVars(pathToSourceFolder) mf
  716.     }
  717.     return $mfSubmenuItems
  718. }
  719.  
  720. menu::buildSome mfMenu 
  721.  
  722. markMenuItem metafontMode proof 1
  723.  
  724.  
  725. ################################################################
  726. #                Main Menus and Submenus procs                 #
  727. ################################################################
  728.  
  729. proc Mf::menuProc {menu item} {
  730.     global MFfullfilename MFdirfilename MFtailfilename #
  731.     global MFbasefilename MFextfilename MFoutputfolder #
  732.     global MfmodeVars useWorkFold MfworkFolder
  733.     global cmdline name
  734.     switch $item {
  735.         "switchToMetafont" {app::launchFore $MfmodeVars(mfAppSig)}
  736.         "runTheBuffer" {
  737.             Mf::setnames [win::Current]
  738.             Mf::checkdirty
  739.             Mf::runbufferProc}
  740.         "saveAndRun" {
  741.             save
  742.             Mf::setnames [win::Current]
  743.             Mf::runbufferProc
  744.             }
  745.         "runAFile" {
  746.             catch {getfile "Select a \".mf\" file to process"}  name
  747.             Mf::setnames $name
  748.             edit $MFfullfilename
  749.             if {[file exists $MFfullfilename]} {
  750.                 Mf::runbufferProc
  751.                 }
  752.             }
  753.         "runAFolder" {Mf::runafolderProc}
  754.         "runCurrentFolder"   {Mf::runcurrfoldProc}
  755.         "newFontTemplate" {Mf::newtemplateProc}
  756.     }
  757. }
  758.  
  759. proc Mf::otherfilesProc {submenu item} {
  760.     global MFfullfilename MFdirfilename MFtailfilename #
  761.     global MFbasefilename MFextfilename MFoutputfolder #
  762.     global MfmodeVars MfworkFolder mfAppSig gffile MFcurrentdir
  763.     global Mffolderpath tfmfile vplfile mfwd
  764.     global prefixplf prefixdvi prefixrmall
  765.     global tileLeft tileTop tileWidth errorHeight fromfolder
  766.     
  767.     switch -regexp $item {
  768.     "openplain.mf" {Mf::openplainmfProc}
  769.     "openmodes.mf" {Mf::openmodesmfProc}
  770.     "convertGfToPk"  {
  771.         Mf::setnames [win::Current]
  772.         Mf::findgfFile
  773.         Mf::dopkProc
  774.     }
  775.     "convertGfToDvi"  {
  776.         Mf::setnames [win::Current]
  777.         Mf::findgfFile
  778.         Mf::dodviProc
  779.         set prefixdvi ""
  780.         menu::buildSome otherFiles
  781.     }
  782.     "convert.*\.dvi" {
  783.         Mf::setnames [win::Current]
  784.         Mf::dviToPsProc
  785.         }
  786.     "view.*\.dvi"  {
  787.         Mf::setnames [win::Current]
  788.         Mf::viewdviProc
  789.     }
  790.     "convert.*\.tfm"  {
  791.         Mf::setnames [win::Current]
  792.         Mf::doplProc
  793.         set prefixplf ""
  794.         menu::buildSome otherFiles
  795.         Mf::editplProc
  796.     }
  797.     "tfmToPlAFolder..." {Mf::tftoplafolderProc}
  798.     "tfmToPlCurrentFolder" {Mf::tftoplcurrfoldProc}
  799.     "tfmToPl..." {
  800.         catch {getfile "Select a tfm file"}  tfmfile
  801.         if {$tfmfile == ""} {
  802.         return
  803.         } else {
  804.         Mf::setnames $tfmfile
  805.         Mf::doplProc
  806.         edit -r [file join $MFdirfilename $MFbasefilename.plf]
  807.         }
  808.     }
  809.     "vpToVfAFolder..."  {Mf::vptovfafolderProc}
  810.     "vpToVfCurrentFolder"  {Mf::vptovfcurrfoldProc}
  811.     "vpToVf..." {
  812.         catch {getfile "Select a vpl file"}  vplfile
  813.         if {$vplfile == ""} {
  814.         return
  815.         } else {
  816.         edit -r "$vplfile"
  817.         Mf::setnames $vplfile
  818.         Mf::dovplProc
  819.         }    
  820.     }
  821.     "open.*\.log$" {
  822.         Mf::setnames [win::Current]
  823.         Mf::editlogProc
  824.     }
  825.     "openPropertyList" {
  826.         Mf::setnames [win::Current]
  827.         Mf::editplProc
  828.     }
  829.     "openAllLogFiles" {Mf::allAuxfilesProc log}
  830.     "openAllPropertyLists" {
  831.         Mf::allAuxfilesProc plf
  832.         Mf::allAuxfilesProc pl
  833.     }
  834.     "chooseAFolder..."  {
  835.         catch {get_directory -p "Select a folder."} MFcurrentdir
  836.         if {$MFcurrentdir == ""} { return }
  837.         set prefixrmall ""
  838.         set fromfolder ""
  839.         set Mffolderpath $MFcurrentdir
  840.         menu::buildSome otherFiles
  841.     }
  842.     "currentFolderIs:"  {
  843.         alertnote "Current folder is: $MFcurrentdir"
  844.     }
  845.     "metafontBindings" {
  846.         set mess "KEY BINDINGS AVAILABLE IN METAFONT MODE\n\n"
  847.         append mess "Press 'ctrl-m', release, then hit one of the following letters :\n"
  848.         append mess "  'b'    to process the <b>uffer\n"
  849.         append mess "  'c'    to edit the macro <c>ommands file 'plain.mf'\n"
  850.         append mess "  'd'    to process a <d>irectory\n"
  851.         append mess "  'f'    to process a <f>ile\n"
  852.         append mess "  'g'    to edit the lo<g> file\n"
  853.         append mess "  'i'    to convert gf file to dv<i>\n"
  854.         append mess "  'k'    to convert gf file to p<k>\n"
  855.         append mess "  'l'    to select <l>ocalfont mode\n"
  856.         append mess "  'm'    to edit the <m>odes file 'modes.mf'\n"
  857.         append mess "  'n'    to create a <n>ew font template\n"
  858.         append mess "  'p'    to select <p>roof mode\n"
  859.         append mess "  's'    to select <s>moke mode\n"
  860.         append mess "  't'    to convert <t>fm file to pl\n"
  861.         append mess "  'u'    to select <u>ser defined mode\n"
  862.         append mess "  'v'    to <v>iew the d<v>i\n"
  863.         new -g $tileLeft $tileTop $tileWidth [expr $errorHeight + 60] -n "* Metafont Bindings *" -info $mess
  864.         set start [minPos]
  865.         while {![catch {search -f 1 -s -r 1 {('|<)[a-z-]+('|>)} $start} res]} {
  866.         insertColorEscape [lindex $res 0] 1
  867.         insertColorEscape [lindex $res 1] 0    
  868.         set start [lindex $res 1]
  869.         }
  870.         insertColorEscape 0 5
  871.         insertColorEscape [nextLineStart 0] 0
  872.         refresh
  873.         }
  874.     }
  875. }
  876.  
  877. # Here is a proc to dimm/undimm the items of the OtherFiles submenu
  878. # depending on the existence of auxiliary files
  879. proc Mf::rebuildOtherfiles {name} {
  880.     global MFfullfilename MFdirfilename MFtailfilename #
  881.     global MFbasefilename MFextfilename MFoutputfolder #
  882.     global mfMenu otherFiles
  883.     global MfmodeVars MfworkFolder mfAppSig
  884.     global prefixgf prefixdvi prefixlog prefixtfm prefixplf
  885.     Mf::setnames [win::Current]
  886.     if {![regexp ".mf" $MFtailfilename] && ![regexp ".plf" $MFtailfilename]} {
  887.     set prefixgf "("
  888.     set prefixdvi "("
  889.     set prefixlog "("
  890.     set prefixtfm "("
  891.     set prefixplf "("
  892.     } else {
  893.     if {[file exists [file join $MFoutputfolder $MFbasefilename.log]]} {
  894.         set prefixgf ""
  895.         set prefixlog ""
  896.     } else {
  897.         set prefixgf "("
  898.         set prefixlog "("
  899.     }
  900.     if {[file exists [file join $MFoutputfolder $MFbasefilename.dvi]]} {
  901.         set prefixdvi ""
  902.     } else {
  903.         set prefixdvi "("
  904.     }
  905.     if {[file exists [file join $MFoutputfolder $MFbasefilename.tfm]]} {
  906.         set prefixtfm ""
  907.     } else {
  908.         set prefixtfm "("
  909.     }
  910.     if {[file exists [file join $MFoutputfolder $MFbasefilename.plf]] \
  911.       || [file exists [file join $MFoutputfolder $MFbasefilename.pl]]} {
  912.         set prefixplf ""
  913.     } else {
  914.         set prefixplf "("
  915.     }
  916.     }
  917.     menu::buildSome otherFiles
  918. }
  919.  
  920. # Choosing Metafont printer mode
  921. proc Mf::choosemodeProc {menu item} {
  922.     global MfmodeVars mfModeForPrinter chosenMode
  923.     global proof smoke localfont userDefined
  924.     switch $item {
  925.     "proof" {
  926.         set chosenMode proof
  927.         Mf::choosemodeMark proof
  928.         Mf::dimmOtherfiles
  929.         message "mode proof - no tfm produced"
  930.     }
  931.     "smoke" {
  932.         set chosenMode smoke
  933.         Mf::choosemodeMark smoke
  934.         Mf::dimmOtherfiles
  935.         message "mode smoke - no tfm produced"
  936.     }
  937.     "localfont" {
  938.         set chosenMode localfont
  939.         Mf::choosemodeMark localfont
  940.         Mf::undimmOtherfiles
  941.         message "mode localfont"
  942.     }
  943.     "userDefined" {
  944.         set chosenMode $MfmodeVars(mfModeForPrinter)
  945.         Mf::choosemodeMark userDefined
  946.         Mf::undimmOtherfiles
  947.         message "mode \"$MfmodeVars(mfModeForPrinter)\""
  948.         alertnote "Current user defined mode is \"$MfmodeVars(mfModeForPrinter)\". You can change this in the Current Mode Prefs."
  949.     }
  950.     }
  951. }
  952.  
  953. proc Mf::choosemodeMark {var} {
  954.     Mf::clearAllModes
  955.     markMenuItem metafontMode $var 1
  956. }
  957.  
  958. proc Mf::clearAllModes {} {
  959.     global proof smoke localfont userDefined
  960.     foreach i {"proof" "smoke" "localfont" "userDefined"} {
  961.     markMenuItem metafontMode $i 0
  962.     } 
  963. }
  964.  
  965.  
  966. # Choosing Metafont processing Options
  967. proc Mf::processingoptProc {menu item} {
  968.     global mag magstep magflag magstepflag Mfbasefileflag
  969.     global MfmodeVars Mfbasefile
  970.     switch $item {    
  971.     "mag..." {
  972.         catch {prompt "Choose a magnification" $mag} res
  973.         if {$res == "cancel"} {return}
  974.         if {$res == 1} {
  975.         set magflag 0
  976.         set mag $res
  977.         markMenuItem processingOptions "mag..." $magflag
  978.         } else {
  979.         set magstep 0
  980.         set magstepflag 0
  981.         set magflag 1
  982.         set mag $res
  983.         markMenuItem processingOptions "mag..." $magflag
  984.         markMenuItem processingOptions "magstep..." $magstepflag
  985.         }
  986.     }
  987.     "magstep..." {
  988.         catch {prompt "Choose a magstep coefficient " $magstep} res
  989.         if {$res == "cancel"} {return}
  990.         if {$res == 0} {
  991.         set magstepflag 0
  992.         set magstep $res
  993.         markMenuItem processingOptions "magstep..." $magstepflag
  994.         } else {
  995.         set mag 1
  996.         set magflag 0
  997.         set magstepflag 1
  998.         set magstep $res
  999.         markMenuItem processingOptions "mag..." $magflag
  1000.         markMenuItem processingOptions "magstep..." $magstepflag
  1001.         }
  1002.     }
  1003.     "baseFile..." {
  1004.         catch {getfile "Select a base file"} Mfbasefilepath
  1005.         set Mfbasefile [file tail $Mfbasefilepath] 
  1006.         set Mfbasefileflag 1
  1007.         markMenuItem processingOptions "baseFile..." $Mfbasefileflag
  1008.     }
  1009.     "gfcorners" {Mf::Toggle gfcorners}
  1010.     "imagerules" {Mf::Toggle imagerules}
  1011.     "nodisplays" {Mf::Toggle nodisplays}
  1012.     "notransforms" {Mf::Toggle notransforms}
  1013.     "screenchars" {Mf::Toggle screenchars}
  1014.     "screenstrokes" {Mf::Toggle screenstrokes}
  1015.     "clearAllOptions" {Mf::clearAllOptionsProc}
  1016.     }    
  1017. }
  1018.  
  1019. proc Mf::Toggle {var} {
  1020.     global $var
  1021.     set $var [expr {[set $var] ? 0 : 1}]
  1022.     synchroniseModeVar $var
  1023.     Mf::shadowMf $var
  1024. }
  1025.  
  1026. proc Mf::shadowMf {name} {
  1027.     global gfcorners imagerules nodisplays
  1028.     global notransforms screenchars screenstrokes
  1029.     switch $name {
  1030.     "gfcorners"    {
  1031.         markMenuItem processingOptions gfcorners $gfcorners
  1032.     }
  1033.     "imagerules"    {
  1034.         markMenuItem processingOptions imagerules $imagerules
  1035.     }
  1036.     "nodisplays"    {
  1037.         markMenuItem processingOptions nodisplays $nodisplays
  1038.     }
  1039.     "notransforms"    {
  1040.         markMenuItem processingOptions notransforms $notransforms
  1041.     }
  1042.     "screenchars"    {
  1043.         markMenuItem processingOptions screenchars $screenchars
  1044.     }
  1045.     "screenstrokes"    {
  1046.         markMenuItem processingOptions screenstrokes $screenstrokes
  1047.     }
  1048.     }
  1049. }
  1050.  
  1051. proc Mf::shadowList {name} {
  1052.     global SourceFiles MfmodeVars pathToSourceFolder buildSourceFiles mfSubmenuItems nestingDepth
  1053.         set mfSubmenuItems ""
  1054.         menu::buildSome sourceFiles
  1055. }
  1056.  
  1057. proc Mf::clearAllOptionsProc {} {
  1058.     global gfcorners imagerules nodisplays
  1059.     global notransforms screenchars screenstrokes
  1060.     global mag magflag magstep magstepflag Mfbasefile Mfbasefileflag
  1061.     foreach i {"gfcorners" "imagerules" "nodisplays" "notransforms" "screenchars" "screenstrokes"} {
  1062.     set $i 0
  1063.     Mf::shadowMf $i
  1064.     }
  1065.     set mag 1
  1066.     set magflag 0
  1067.     set magstep 0
  1068.     set magstepflag 0
  1069.     set Mfbasefileflag 0
  1070.     set Mfbasefile ""
  1071.     markMenuItem processingOptions "baseFile..." $Mfbasefileflag
  1072.     markMenuItem processingOptions "mag..." $magflag
  1073.     markMenuItem processingOptions "magstep..." $magstepflag
  1074. }
  1075.  
  1076. proc Mf::dimmOtherfiles {} {
  1077.     enableMenuItem otherFiles "convertTfmToPl" 0
  1078.     enableMenuItem otherFiles "openPropertyList" 0
  1079. }
  1080.  
  1081. proc Mf::undimmOtherfiles {} {
  1082.     enableMenuItem otherFiles "convertTfmToPl" 1
  1083.     enableMenuItem otherFiles "openPropertyList" 1
  1084. }
  1085.  
  1086. proc Mf::removefilesProc {menu item} {
  1087.     global MfmodeVars mfAppSig MFcurrentdir prefixrmall fromfolder Mffolderpath
  1088.     switch $item {    
  1089.     "allLogFiles"  {Mf::deleteallfilesProc log}
  1090.     "allGfFiles"  {Mf::deleteallfilesProc gf}
  1091.     "allPkFiles"  {Mf::deleteallfilesProc pk}
  1092.     "allDviFiles" {Mf::deleteallfilesProc dvi}
  1093.     "allTfmFiles" {Mf::deleteallfilesProc tfm}
  1094.     "allVfFiles" {Mf::deleteallfilesProc vf}
  1095.     "allPlFiles" {Mf::deleteallfilesProc plf}
  1096.     "allVplFiles" {Mf::deleteallfilesProc vpl}
  1097.     "allOfThem" {
  1098.         foreach ext {"log" "gf" "pk" "dvi" "tfm" "vf" "plf" "vpl"} {
  1099.         Mf::deleteallfilesProc $ext
  1100.         }
  1101.     }
  1102.     }
  1103.     Mf::rebuildOtherfiles ""
  1104. }
  1105.  
  1106.  
  1107. ##################################################
  1108. #                                                #
  1109. #   Procs to process the Metafont source files   #
  1110. #                                                #
  1111. ##################################################
  1112.  
  1113. proc Mf::runbufferProc {} {
  1114.     global MFfullfilename MFdirfilename MFtailfilename #
  1115.     global MFbasefilename MFextfilename MFoutputfolder #
  1116.     global cmdline addcmdline MfmodeVars mfAppSig 
  1117.     global chosenMode resol    
  1118.     if {[string length $MfmodeVars(mfAppSig)]} {
  1119.     app::launchFore "$MfmodeVars(mfAppSig)"
  1120.     switch $MfmodeVars(mfAppSig) {
  1121.         "CMT3" {     
  1122.         Mf::buildCMTcmdLine
  1123.         Mf::doMfscript
  1124.         }
  1125.         "OzMF" {
  1126.         if {$chosenMode == "proof"} {
  1127.             Mf::doMfscript
  1128.             Mf::updateprefixes
  1129.         } else {
  1130.             set resol "[Mf::findmoderes]"
  1131.             Mf::buildOZmakeLine
  1132.             Mf::createmakefile
  1133.             Mf::runmakefile
  1134.             Mf::updateprefixes
  1135.         }
  1136.         }
  1137.     }
  1138.     menu::buildSome otherFiles
  1139.     } else {
  1140.     alertnote "No Mf app. selected. Select it in the Current mode preferences."
  1141.     }
  1142. }
  1143.  
  1144. proc Mf::runafolderProc {} {
  1145.     global MFfullfilename MFdirfilename MFtailfilename #
  1146.     global MFbasefilename MFextfilename MFoutputfolder #
  1147.     global cmdline MfmodeVars mfAppSig MFcurrentdir
  1148.     global chosenMode resol prefixrmall
  1149.     global filesindir ext MfworkFolder Mffolderpath fromfolder
  1150.     
  1151.     catch {get_directory -p "Select a folder."} Mffolderpath
  1152.     set MFcurrentdir $Mffolderpath
  1153.     if {$Mffolderpath == ""} { return }
  1154.     set prefixrmall ""
  1155.     set ext ".mf"
  1156.     set filesindir [glob -nocomplain -dir [file join $Mffolderpath] *$ext]
  1157.     if {[llength $filesindir] == 0} {
  1158.     alertnote "No \"$ext\" file in this folder."
  1159.     return
  1160.     } 
  1161.     if {[string length $MfmodeVars(mfAppSig)]} {
  1162.     switch $MfmodeVars(mfAppSig) {
  1163.         "CMT3" {Mf::domaketexpk}
  1164.         "OzMF" {Mf::domaketexpk}
  1165.     }
  1166.     set fromfolder ""
  1167.     menu::buildSome otherFiles
  1168.     } else {
  1169.     alertnote "No Mf app. selected. Select it in the Current mode preferences."
  1170.     }                    
  1171. }    
  1172.  
  1173. proc Mf::runcurrfoldProc {} {
  1174.     global MFfullfilename MFdirfilename MFtailfilename #
  1175.     global MFbasefilename MFextfilename MFoutputfolder #
  1176.     global cmdline MfmodeVars mfAppSig MFcurrentdir
  1177.     global chosenMode resol prefixrmall
  1178.     global filesindir ext MfworkFolder Mffolderpath fromfolder
  1179.     if {$MFcurrentdir == ""}  {
  1180.     alertnote "No folder currently selected"
  1181.     return
  1182.     }
  1183.     set prefixrmall ""
  1184.     set ext ".mf"
  1185.     set Mffolderpath:  $MFcurrentdir
  1186.     set filesindir [glob -nocomplain -dir [file join $Mffolderpath] *$ext]
  1187.     if {[llength $filesindir] == 0} {
  1188.     alertnote "No \"$ext\" file in this folder."
  1189.     return 
  1190.     } 
  1191.     if {[string length $MfmodeVars(mfAppSig)]} {
  1192.     switch $MfmodeVars(mfAppSig) {
  1193.         "CMT3" {Mf::domaketexpk}
  1194.         "OzMF" {Mf::domaketexpk}
  1195.     }
  1196.     set fromfolder ""
  1197.     menu::buildSome otherFiles
  1198.     } else {
  1199.     alertnote "No Mf app. selected. Select it in the Current mode preferences."
  1200.     }                    
  1201. }    
  1202.     
  1203. proc Mf::domaketexpk {} {
  1204.     global MFfullfilename MFdirfilename MFtailfilename #
  1205.     global MFbasefilename MFextfilename MFoutputfolder #
  1206.     global cmdline MfmodeVars mfAppSig
  1207.     global chosenMode resol
  1208.     global filesindir ext MfworkFolder Mffolderpath fromfolder
  1209.     if {[file exists [file join $Mffolderpath tmpall.make]]} {
  1210.     file delete [file join $Mffolderpath tmpall.make]
  1211.     }
  1212.     switch [buttonAlert "OK to process all \"$ext\" files from $Mffolderpath ?" "yes" "cancel" ] {
  1213.     "yes" {
  1214.         set fileId [open [file join $Mffolderpath tmpall.make] a+] 
  1215.         set resol  "[Mf::findmoderes]"
  1216.         message "$resol"
  1217.         foreach file $filesindir {
  1218.         # We open each file because in the case when no mf file is open
  1219.         # we get problems with unrecognized MfmodeVars values
  1220.         edit -w $file
  1221.         set MFfullfilename $file
  1222.         set MFtailfilename [file tail $file]
  1223.         Mf::buildOZmakeLine
  1224.         # message "$cmdline"
  1225.         puts $fileId $cmdline
  1226.         }
  1227.         close $fileId
  1228.         Mf::runmakeallfile
  1229.     }
  1230.     "cancel" {
  1231.         app::launchFore "ALFA"
  1232.         return 
  1233.     }
  1234.     }
  1235. }
  1236.  
  1237. proc Mf::checkdirty {} {
  1238.     if {[winDirty]} {
  1239.     case [askyesno -c "Dirty window '[lindex [winNames] 0]'. Do you want to save it ?"] in {
  1240.         "yes" {save}
  1241.         "no" {}
  1242.         "cancel" {return}
  1243.     }
  1244.     }
  1245. }
  1246.  
  1247.  
  1248. #################################
  1249. #                               #
  1250. #   Scripts and Command Lines   #
  1251. #                               #
  1252. #################################
  1253.  
  1254. proc Mf::buildCMTcmdLine {} {
  1255.     global MFfullfilename MFdirfilename MFtailfilename #
  1256.     global MFbasefilename MFextfilename MFoutputfolder #
  1257.     global cmdline MfmodeVars chosenMode mfModeForPrinter MfworkFolder useWorkFold
  1258.     global proof smoke localfont userDefined script
  1259.     global gfcorners imagerules nodisplays
  1260.     global notransforms screenchars screenstrokes
  1261.     global mag magstep magflag magstepflag Mfbasefile Mfbasefileflag
  1262.     set cmdline "mf "
  1263.     #    choosing the mode
  1264.     if {$chosenMode != "proof"} {
  1265.     if {$chosenMode == "smoke" || $chosenMode == "localfont"} {
  1266.         append cmdline "\\mode=$chosenMode; "
  1267.     } else {
  1268.         append cmdline "\\mode=$MfmodeVars(mfModeForPrinter);"
  1269.     }
  1270.     } else {
  1271.     append cmdline "\\ "
  1272.     }
  1273.     #   Do we magnify ?
  1274.     if {$magflag == 1} {
  1275.     append cmdline "mag=$mag; "
  1276.     } elseif {$magstepflag == 1} {
  1277.     append cmdline "mag=magstep\($magstep\); "
  1278.     }
  1279.     #    Add the (optional!) options if the corresponding flag is set
  1280.     if {$screenchars} {append cmdline "screenchars; "}
  1281.     if {$screenstrokes} {
  1282.     if {$chosenMode != "proof"} {
  1283.         alertnote "The \"screenstrokes\" option is for proof mode only. I'll ignore it."
  1284.         Mf::Toggle screenstrokes
  1285.         Mf::shadowMf screenstrokes
  1286.     } else {
  1287.         append cmdline "screenstrokes; "
  1288.     }
  1289.     }
  1290.     if {$imagerules} {
  1291.     append cmdline "imagerules; "
  1292.     }
  1293.     if {$gfcorners} {
  1294.     append cmdline "gfcorners; "
  1295.     }
  1296.     if {$nodisplays} {
  1297.     if {$chosenMode != "proof"} {
  1298.         alertnote "The \"nodisplays\" option is for proof mode only. I'll ignore it."
  1299.     } elseif {$screenchars || $screenstrokes} {
  1300.         beep 
  1301.         alertnote "Contradictory options : you can't use \"nodisplays\" with \"screenchars\" or \"screenstrokes\". I'll ignore it."
  1302.         Mf::Toggle nodisplays
  1303.         Mf::shadowMf nodisplays
  1304.     } else {
  1305.         append cmdline "nodisplays; "
  1306.     }
  1307.     }
  1308.     if {$notransforms} {
  1309.     append cmdline "notransforms; "
  1310.     }
  1311.     #    Input a base file if any
  1312.     if {$Mfbasefileflag == 1} {
  1313.     append cmdline "input $Mfbasefile;"
  1314.     }
  1315.     append cmdline "input $MFtailfilename;"
  1316.     #   Now the file to process. Since version 2.2.1 of CMaCTeX Metafont there is a new syntax 
  1317.     #     for the Apple event : the destination folder is included in the script line
  1318.     #     and introduced by -@
  1319. #     if {[lindex [Mf::getMfVersion] 1] > 2.2} {
  1320. #     append cmdline " -@ [set MFoutputfolder]:"
  1321. #     }
  1322.     set cmdline [curlyq $cmdline]
  1323.     #     Finally we update prefixes to rebuild accordingly the Other Files submenu
  1324.     Mf::updateprefixes
  1325. }
  1326.  
  1327. # OzMetafont cannot receive a complete command line through an Apple Event. 
  1328. # The workaround is to create a ".make" file which OzMetafont will process 
  1329. # with its built-in MakeTeXPK.
  1330. #         (Good) side effect : the "pk" files will be done in the same time,
  1331. #         thus no need to invoke gftopk after that.
  1332. proc Mf::buildOZmakeLine {} {
  1333.     global cmdline MFfullfilename MFtailfilename MfmodeVars chosenMode
  1334.     global proof smoke localfont userDefined script resol mfModeForPrinter
  1335.     global gfcorners imagerules nodisplays
  1336.     global notransforms screenchars screenstrokes
  1337.     global mag magstep magflag magstepflag Mfbasefile Mfbasefileflag
  1338.     set cmdline "MakeTeXPK [file rootname $MFtailfilename] "
  1339.     # What is the resolution corresponding to the printer mode ? We look for it in the
  1340.     # modes.mf file.
  1341.     append cmdline "[lindex $resol 1] [lindex $resol 1] "
  1342.     #   Do we magnify ?
  1343.     if {$magflag == 1} {
  1344.     append cmdline "$mag "
  1345.     } elseif {$magstepflag == 1} {
  1346.     append cmdline "magstep\($magstep\) "
  1347.     } else {
  1348.     append cmdline "1 "
  1349.     }
  1350.     #   Choose the mode
  1351.     if {$chosenMode == "localfont"} {
  1352.     append cmdline     "[lindex $resol 0]"    
  1353.     } elseif {$chosenMode == "proof" || $chosenMode == "smoke"} {
  1354.     append cmdline "$chosenMode"
  1355.     } else {
  1356.     append cmdline $MfmodeVars(mfModeForPrinter)
  1357.     }
  1358.     #    Add the (optional!) options if the corresponding flag is set
  1359.     if {$screenchars} {append cmdline ";screenchars"}
  1360.     if {$screenstrokes} {
  1361.     if {$chosenMode != "proof"} {
  1362.         alertnote "The \"screenstrokes\" option is for proof mode only. I'll ignore it."
  1363.         Mf::Toggle screenstrokes
  1364.         Mf::shadowMf screenstrokes
  1365.     } else {
  1366.         append cmdline ";screenstrokes"
  1367.     }
  1368.     }
  1369.     if {$imagerules} {
  1370.     append cmdline ";imagerules"
  1371.     }
  1372.     if {$gfcorners} {
  1373.     append cmdline ";gfcorners"
  1374.     }
  1375.     if {$nodisplays} {
  1376.     if {$chosenMode != "proof"} {
  1377.         alertnote "The \"nodisplays\" option is for proof mode only. I'll ignore it."
  1378.     } elseif {$screenchars || $screenstrokes} {
  1379.         beep 
  1380.         alertnote "Contradictory options : you can't use \"nodisplays\" with \"screenchars\" or \"screenstrokes\". I'll ignore it."
  1381.         Mf::Toggle nodisplays
  1382.         Mf::shadowMf nodisplays
  1383.     } else {
  1384.         append cmdline ";nodisplays"
  1385.     }
  1386.     }
  1387.     if {$notransforms} {
  1388.     append cmdline ";notransforms"
  1389.     }
  1390.     #   Input a base file if any
  1391.     if {$Mfbasefileflag == 1} {
  1392.     append cmdline ";input $Mfbasefile"
  1393.     }
  1394.     #     Finally we update prefixes to rebuild the "Other Files" submenu
  1395.     Mf::updateprefixes
  1396. }
  1397.  
  1398. proc Mf::doMfscript {} {
  1399.     global cmdline MFfullfilename MFoutputfolder
  1400.     global MfmodeVars mfAppSig
  1401.     switch $MfmodeVars(mfAppSig) {
  1402.     "CMT3" {
  1403.         set name [file join $MFoutputfolder ""]
  1404.         eval "AEBuild -t 6000 'CMT3'" CMTX exec {----} [list $cmdline] dest [tclAE::build::alis $name]
  1405.     }
  1406.     "OzMF" {
  1407.         app::launchFore "OzMF"
  1408.         dosc -c 'OzMF' -k 'aevt' -e 'odoc' -t 600 -r -f $MFfullfilename
  1409.     }
  1410.     }
  1411. }
  1412.  
  1413. proc Mf::createmakefile {} {
  1414.     global MFfullfilename MFdirfilename MFtailfilename #
  1415.     global MFbasefilename MFextfilename MFoutputfolder #
  1416.     global cmdline
  1417.     set fileId [open "[file dirname $MFfullfilename]:tmp.make" w+] 
  1418.     puts $fileId $cmdline
  1419.     close $fileId
  1420. }
  1421.  
  1422. proc Mf::runmakefile {} {
  1423.     global MFfullfilename MFdirfilename MFtailfilename #
  1424.     global MFbasefilename MFextfilename MFoutputfolder #
  1425.     app::launchFore "OzMF"
  1426.     dosc -c 'OzMF' -k 'aevt' -e 'odoc' -t 600 -r -f [file join $MFdirfilename tmp.make]
  1427. }
  1428.  
  1429. proc Mf::runmakeallfile {} {
  1430.     global Mffolderpath MfmodeVars mfAppSig
  1431.     switch $MfmodeVars(mfAppSig) {
  1432.     "CMT3" {
  1433.         app::launchFore "CMT9"
  1434.         dosc -c 'CMT9' -k 'aevt' -e 'odoc' -t 600 -r -f [file join $Mffolderpath tmpall.make]
  1435.     }
  1436.     "OzMF" {
  1437.         app::launchFore "OzMF"
  1438.         dosc -c 'OzMF' -k 'aevt' -e 'odoc' -t 600 -r -f [file join $Mffolderpath tmpall.make]                        
  1439.     }
  1440.     }
  1441. }
  1442.  
  1443. proc Mf::updateprefixes {} {
  1444.     global prefixtfm prefixdvi prefixplf prefixgf prefixlog chosenMode
  1445.     if {$chosenMode == "proof"  || $chosenMode == "smoke"} {
  1446.     set prefixtfm "("
  1447.     } else {
  1448.     set prefixtfm ""
  1449.     }
  1450.     set prefixplf "("
  1451.     set prefixdvi "("
  1452.     set prefixgf ""
  1453.     set prefixlog ""
  1454. }
  1455.  
  1456.  
  1457. #########################################
  1458. #                                       #
  1459. #   Procs to run the related programs   #
  1460. #                                       #
  1461. #########################################
  1462.  
  1463. # This proc calls up gftopk
  1464. proc Mf::dopkProc {} {
  1465.     global MFfullfilename MFdirfilename MFtailfilename #
  1466.     global MFbasefilename MFextfilename MFoutputfolder #
  1467.     global gffile MfmodeVars MfworkFolder mfAppSig mfset 
  1468.     global mfwd Mffolderpath 
  1469.     switch $MfmodeVars(mfAppSig) {
  1470.     "CMT3" {
  1471.         if {![file exists [file join $MFoutputfolder $gffile]]} {
  1472.         alertnote "Can't find file $gffile."
  1473.         return
  1474.         }
  1475.         set pkcmdline "gftopk [file join $MFoutputfolder $gffile]"
  1476.         app::launchFore "CMTe"
  1477.         set pkcmdline [curlyq $pkcmdline]
  1478.         eval "AEBuild 'CMTe'" CMTX exec {----} [list $pkcmdline]
  1479.     }
  1480.     "OzMF" {
  1481.         if {![file exists [file join $mfwd $gffile]]} {
  1482.         alertnote "Can't find file $gffile. Check that the \"delete_gf\" flag in OzMetafont configs is set to false."
  1483.         return
  1484.         }
  1485.         app::launchFore "OzMF"
  1486.         dosc -c 'OzMF' -k 'aevt' -e 'odoc' -t 6000 -r -f [file join $mfwd $gffile]
  1487.     }
  1488.     }
  1489. }
  1490.  
  1491. # This proc calls up gftodvi
  1492. proc Mf::dodviProc {} {
  1493.     global MFfullfilename MFdirfilename MFtailfilename #
  1494.     global MFbasefilename MFextfilename MFoutputfolder #
  1495.     global gffile MfmodeVars MfworkFolder mfAppSig mfset 
  1496.     global mfwd Mffolderpath MFoutputfolder
  1497.     switch $MfmodeVars(mfAppSig) {
  1498.     "CMT3" {
  1499.         if {![file exists [file join $MFoutputfolder $gffile]]} {
  1500.         alertnote "Can't find file $gffile."
  1501.         return
  1502.         }
  1503.         if {[app::isRunning CMTd]} {
  1504.         sendQuitEvent 'CMTd'
  1505.         alertnote "Click to convert [file tail $gffile] to dvi."
  1506.         }
  1507.         set dvicmdline "gftodvi [file join $MFoutputfolder $gffile]"
  1508.         app::launchFore "CMTd"
  1509.         set dvicmdline [curlyq $dvicmdline]
  1510.         eval "AEBuild 'CMTd'" CMTX exec {----} [list $dvicmdline]
  1511.     }
  1512.     "OzMF" {
  1513.         if {![file exists [file join $mfwd $gffile]]} {
  1514.         alertnote "Can't find file $gffile. Check that the \"delete_gf\" flag in OzMetafont configs is set to false."
  1515.         return
  1516.         }
  1517.         app::launchFore "OzMF"
  1518.         dosc -c 'OzMF' -k 'aevt' -e 'odoc' -t 6000 -r -f [file join $mfwd $gffile]
  1519.     }
  1520.     }
  1521. }
  1522.  
  1523. # This proc calls up a previewer to view the dvi file produced by gftodvi.
  1524. # For CMaCTeX, it looks in the output folder, then sends the Apple Event to dvipreview :
  1525. # note : if you prefer xdvi, change the signature from PIVD to CMT8)
  1526. # for Oz, it looks in the current window's folder then sends the event to OzTeX.
  1527. proc Mf::viewdviProc {} {
  1528.     global MFfullfilename MFdirfilename MFtailfilename #
  1529.     global MFbasefilename MFextfilename MFoutputfolder #
  1530.     global gffile MfmodeVars MfworkFolder mfAppSig mfset 
  1531.     global mfwd Mffolderpath rootname 
  1532.     switch $MfmodeVars(mfAppSig) {
  1533.     "CMT3" {
  1534.         if {![file exists [file join $MFoutputfolder $MFbasefilename.dvi]]} {
  1535.         alertnote "Can't find file $MFbasefilename.dvi."
  1536.         return
  1537.         }
  1538.         app::launchFore "PIVD"
  1539.         # app::launchElseTryThese "PIVD" "CMT8"
  1540.         dosc -c 'PIVD' -k 'aevt' -e 'odoc' -r -f [file join $MFoutputfolder $MFbasefilename.dvi]
  1541.     }
  1542.     "OzMF" {
  1543.         if {![file exists [file join $MFdirfilename $MFbasefilename.dvi]]} {
  1544.         alertnote "Can't find file $MFbasefilename.dvi."
  1545.         return
  1546.         }
  1547.         app::launchFore "OTEX"
  1548.         dosc -c 'OTEX' -k 'aevt' -e 'odoc' -t 600 -r -f [file join $MFdirfilename $MFbasefilename.dvi]
  1549.     }
  1550.     }
  1551. }
  1552.  
  1553. # This proc calls up CMacTeX dvips
  1554. proc Mf::dviToPsProc {} {
  1555.     global MFfullfilename MFdirfilename MFtailfilename #
  1556.     global MFbasefilename MFextfilename MFoutputfolder #
  1557.     if {![file exists [file join $MFoutputfolder $MFbasefilename.dvi]]} {
  1558.     alertnote "Can't find file $MFbasefilename.dvi."
  1559.     return
  1560.     }
  1561.     app::launchFore "CMT1"
  1562.     dosc -c 'CMT1' -k 'aevt' -e 'odoc' -r -f [file join $MFoutputfolder $MFbasefilename.dvi]   
  1563. }
  1564.  
  1565.  
  1566. # This proc calls up tftopl
  1567. proc Mf::doplProc {} {
  1568.     global MFfullfilename MFdirfilename MFtailfilename #
  1569.     global MFbasefilename MFextfilename MFoutputfolder #
  1570.     global rootname MfmodeVars MfworkFolder mfAppSig tfmfile mfset 
  1571.     global mfwd Mffolderpath MFoutputfolder
  1572.     switch $MfmodeVars(mfAppSig) {
  1573.     "CMT3" {     
  1574.         if {[app::isRunning CMTk]} {
  1575.         sendQuitEvent 'CMTk'
  1576.         alertnote "Click to proceed."
  1577.         }
  1578.         if {$mfset} {
  1579.         set mfwd $Mffolderpath
  1580.         } else {set mfwd $MFoutputfolder}
  1581.         if {$tfmfile != ""} {
  1582.         set plcmdline "tftopl [file join $MFdirfilename $MFbasefilename.tfm] [file join $MFdirfilename $MFbasefilename.plf]"
  1583.         set tfmfile ""
  1584.         } else {
  1585.         if {![file exists [file join $mfwd $MFbasefilename.tfm]]} {
  1586.             alertnote "Can't find file $MFbasefilename.tfm. Check your mode (no tfm in proof or smoke modes)."
  1587.             return
  1588.         }
  1589.         set plcmdline "tftopl [file join $mfwd $MFbasefilename.tfm] [file join $mfwd $MFbasefilename.plf]"
  1590.         }
  1591.         app::launchFore "CMTk"
  1592.         set plcmdline [curlyq $plcmdline]
  1593.         eval "AEBuild -r 'CMTk'" CMTX exec {----} [list $plcmdline]
  1594.     }
  1595.     "OzMF" {
  1596.         if {[app::isRunning OzMF]} {
  1597.         sendQuitEvent 'OzMF'
  1598.         alertnote "Click to proceed."
  1599.         }
  1600.         if {$mfset} {
  1601.         set mfwd $Mffolderpath
  1602.         } else {set mfwd $MFdirfilename}
  1603.         if {![file exists [file join $mfwd $MFbasefilename.tfm]]} {
  1604.         alertnote "Can't find file $MFbasefilename.tfm. Check that the \"delete_tfm\" flag in OzMetafont configs is set to false."
  1605.         return
  1606.         }
  1607.         app::launchFore "OzMF"
  1608.         if {$tfmfile != ""} {
  1609.         dosc -c 'OzMF' -k 'aevt' -e 'odoc' -t 600 -r -f $tfmfile                
  1610.         set tfmfile ""
  1611.         } else {
  1612.         dosc -c 'OzMF' -k 'aevt' -e 'odoc' -t 600 -r -f [file join $mfwd $MFbasefilename.tfm]
  1613.         }
  1614.     }
  1615.     }
  1616. }
  1617.  
  1618. proc Mf::editlogProc {}  {
  1619.     global MFfullfilename MFdirfilename MFtailfilename #
  1620.     global MFbasefilename MFextfilename MFoutputfolder #
  1621.     global MfmodeVars MfworkFolder mfAppSig gffile
  1622.     global tfmfile vplfile mfwd prefixplf prefixdvi
  1623.     
  1624.     switch $MfmodeVars(mfAppSig) {
  1625.     "CMT3" {     
  1626.         if {![file exists [file join $MFoutputfolder $MFbasefilename.log]]} {
  1627.         alertnote "Can't find file $MFbasefilename.log."
  1628.         return
  1629.         } else {
  1630.         edit -r [file join $MFoutputfolder $MFbasefilename.log]
  1631.         }
  1632.     }
  1633.     "OzMF" {
  1634.         if {![file exists [file join $MFdirfilename $MFbasefilename.log]]} {
  1635.         alertnote "Can't find file $MFbasefilename.log. Check that the \"delete_log\" flag in OzMetafont configs is set to false."
  1636.         return
  1637.         } else {
  1638.         edit -r [file join $MFdirfilename $MFbasefilename.log]
  1639.         }
  1640.     }
  1641.     }
  1642. }
  1643.  
  1644. proc Mf::editplProc {} {
  1645.     global MFfullfilename MFdirfilename MFtailfilename #
  1646.     global MFbasefilename MFextfilename MFoutputfolder #
  1647.     global rootname MfmodeVars MfworkFolder mfAppSig 
  1648.     global mfwd tfmfile MFoutputfolder
  1649.     switch $MfmodeVars(mfAppSig) {
  1650.     "CMT3" {     
  1651.         if {[file exists [file join $MFoutputfolder $MFbasefilename.plf]]} {
  1652.         edit -r [file join $MFoutputfolder $MFbasefilename.plf]
  1653.         }
  1654.     }
  1655.     "OzMF" {
  1656.         if {$tfmfile != ""} {
  1657.         if {[file exists [file join [file dirname $tfmfile] [file rootname [file tail $tfmfile]].pl]]} {
  1658.             edit -r [file join [file dirname $tfmfile] [file rootname [file tail $tfmfile]].pl]
  1659.         } else {
  1660.             alertnote "Can't find [file rootname [file tail $tfmfile]].pl"
  1661.         }
  1662.         } else {
  1663.         if {[file exists [file join $MFdirfilename $MFbasefilename.pl]]} {
  1664.             edit -r [file join $MFdirfilename $MFbasefilename.pl]
  1665.         } else {
  1666.             alertnote "Can't find $MFbasefilename.pl in $MFdirfilename."
  1667.         }
  1668.         }
  1669.     }
  1670.     }
  1671.     set prefixplf ""
  1672.     menu::buildSome otherFiles
  1673. }
  1674.  
  1675. proc Mf::dovplProc {} {
  1676.     global MFfullfilename MFdirfilename MFtailfilename #
  1677.     global MFbasefilename MFextfilename MFoutputfolder #
  1678.     global rootname MfmodeVars MfworkFolder mfAppSig vplfile mfset 
  1679.     global mfwd Mffolderpath MFoutputfolder
  1680.     switch $MfmodeVars(mfAppSig) {
  1681.     "CMT3" {     
  1682.         if {[app::isRunning CMTm]} {
  1683.         sendQuitEvent 'CMTm'
  1684.         alertnote "Click to proceed."
  1685.         }
  1686.         if {$mfset} {
  1687.         set mfwd $Mffolderpath
  1688.         } else {set mfwd $MFoutputfolder}
  1689.         if {$vplfile != ""} {
  1690.         set plcmdline "vptovf [file join $MFdirfilename $MFbasefilename.vpl] [file join $MFdirfilename $MFbasefilename.vf] [file join $MFdirfilename $MFbasefilename.tfm]"
  1691.         set vplfile ""
  1692.         } else {
  1693.         if {![file exists [file join $mfwd $MFbasefilename.vpl]]} {
  1694.             alertnote "Can't find file $MFbasefilename.vpl."
  1695.             return
  1696.         }
  1697.         set plcmdline "tftopl [file join $mfwd $MFbasefilename.vpl] [file join $mfwd $MFbasefilename.vf] [file join $mfwd $MFbasefilename.tfm]"
  1698.         }
  1699.         app::launchFore "CMTm"
  1700.         set plcmdline [curlyq $plcmdline]
  1701.         eval "AEBuild -r 'CMTm'" CMTX exec {----} [list $plcmdline]
  1702.     }
  1703.     "OzMF" {
  1704.         if {[app::isRunning OzMF]} {
  1705.         sendQuitEvent 'OzMF'
  1706.         alertnote "Click to proceed."
  1707.         }
  1708.         if {$mfset} {
  1709.         set mfwd $Mffolderpath
  1710.         } else {set mfwd $MFdirfilename}
  1711.         if {![file exists [file join $mfwd $MFbasefilename.vpl]]} {
  1712.         alertnote "Can't find file $MFbasefilename.vpl."
  1713.         return
  1714.         }
  1715.         app::launchFore "OzMF"
  1716.         if {$vplfile != ""} {
  1717.         dosc -c 'OzMF' -k 'aevt' -e 'odoc' -t 600 -r -f $vplfile                
  1718.         set vplfile ""
  1719.         } else {
  1720.         dosc -c 'OzMF' -k 'aevt' -e 'odoc' -t 600 -r -f [file join $mfwd $MFbasefilename.vpl]
  1721.         app::launchFore "ALFA"
  1722.         }
  1723.     }
  1724.     }
  1725. }
  1726.  
  1727. proc Mf::tftoplafolderProc {} {
  1728.     global MFfullfilename MFdirfilename MFtailfilename #
  1729.     global MFbasefilename MFextfilename MFoutputfolder #
  1730.     global MfmodeVars mfAppSig MFcurrentdir
  1731.     global filesindir ext Mffolderpath mfset
  1732.     catch {get_directory -p "Select a folder."} Mffolderpath
  1733.     if {$Mffolderpath == ""} { return }
  1734.     set MFcurrentdir $Mffolderpath
  1735.     Mf::tftoplallProc
  1736. }
  1737.  
  1738. proc Mf::tftoplcurrfoldProc {} {
  1739.     global MFfullfilename MFdirfilename MFtailfilename #
  1740.     global MFbasefilename MFextfilename MFoutputfolder #
  1741.     global MfmodeVars mfAppSig MFcurrentdir
  1742.     global filesindir ext Mffolderpath mfset
  1743.     if {$MFcurrentdir == ""}  {alertnote "No folder currently selected"
  1744.     return}
  1745.     set prefixrmall ""
  1746.     set Mffolderpath $MFcurrentdir
  1747.     Mf::tftoplallProc
  1748. }
  1749.  
  1750. proc Mf::tftoplallProc {} {
  1751.     global MFfullfilename MFdirfilename MFtailfilename #
  1752.     global MFbasefilename MFextfilename MFoutputfolder #
  1753.     global MfmodeVars mfAppSig MFcurrentdir
  1754.     global filesindir ext Mffolderpath mfset
  1755.     set ext ".tfm"
  1756.     set mfset 1
  1757.     set filesindir [glob -nocomplain -dir [file join $Mffolderpath] *$ext]
  1758.     if {[llength $filesindir] == 0} {
  1759.     alertnote "No \"$ext\" file in this folder."
  1760.     set mfset 0
  1761.     return
  1762.     } 
  1763.     switch [buttonAlert "Process all the tfm files in $Mffolderpath with tftopl ? " "yes" "cancel" ] {
  1764.     "yes" {
  1765.         foreach tfmfile $filesindir {
  1766.         Mf::setnames $tfmfile
  1767.         if {[file exists [file join $Mffolderpath $MFbasefilename.tfm]]} {
  1768.             Mf::doplProc
  1769.             app::launchFore "ALFA"
  1770.         }
  1771.         }
  1772.     }
  1773.     "cancel" {}
  1774.     }
  1775.     set mfset 0
  1776.     switch $MfmodeVars(mfAppSig) {
  1777.     "CMT3" {set extpl "plf"}
  1778.     "OzMF" {set extpl "pl"}
  1779.     }
  1780.     foreach tfmfile $filesindir {
  1781.     Mf::setnames $tfmfile
  1782.     if {[file exists [file join $Mffolderpath $MFbasefilename.$extpl]]} {
  1783.         edit -r [file join $Mffolderpath $MFbasefilename.$extpl]
  1784.     }
  1785.     }
  1786.     menu::buildSome otherFiles
  1787. }
  1788.  
  1789. proc Mf::vptovfafolderProc {} {
  1790.     global MFfullfilename MFdirfilename MFtailfilename #
  1791.     global MFbasefilename MFextfilename MFoutputfolder #
  1792.     global vplfile Mffolderpath MFcurrentdir
  1793.     global filesindir ext mfset
  1794.     catch {get_directory -p "Select a folder."} Mffolderpath
  1795.     set MFcurrentdir $Mffolderpath
  1796.     if {$Mffolderpath == ""} { return }
  1797.     Mf::vptovfallProc
  1798. }    
  1799.  
  1800. proc Mf::vptovfcurrfoldProc {} {
  1801.     global MFfullfilename MFdirfilename MFtailfilename #
  1802.     global MFbasefilename MFextfilename MFoutputfolder #
  1803.     global vplfile Mffolderpath MFcurrentdir
  1804.     global filesindir ext mfset
  1805.     if {$MFcurrentdir == ""}  {alertnote "No folder currently selected"
  1806.     return}
  1807.     set prefixrmall ""
  1808.     set Mffolderpath:  $MFcurrentdir
  1809.     Mf::vptovfallProc
  1810. }    
  1811.  
  1812. proc Mf::vptovfallProc {} {
  1813.     global MFfullfilename MFdirfilename MFtailfilename #
  1814.     global MFbasefilename MFextfilename MFoutputfolder #
  1815.     global vplfile Mffolderpath MFcurrentdir
  1816.     global filesindir ext mfset
  1817.     set ext "vpl"
  1818.     set mfset 1
  1819.     set filesindir [glob -nocomplain -dir [file join $Mffolderpath] *.$ext]
  1820.     if {[llength $filesindir] == 0} {
  1821.     alertnote "No \"$ext\" file in this folder."
  1822.     set mfset 0
  1823.     return
  1824.     } 
  1825.     switch [buttonAlert "Process all the vpl files in $Mffolderpath with vptovf ? " "yes" "cancel" ] {
  1826.     "yes" {
  1827.         foreach vplfile $filesindir {
  1828.         Mf::setnames $vplfile
  1829.         edit -r "$vplfile"
  1830.         Mf::dovplProc
  1831.         app::launchFore "ALFA"
  1832.         }
  1833.     }
  1834.     "cancel" {}
  1835.     }
  1836.     set mfset 0
  1837.     menu::buildSome otherFiles
  1838. }
  1839.  
  1840.  
  1841. #####################
  1842. #                   #
  1843. #   Utility procs   #
  1844. #                   #
  1845. #####################
  1846.  
  1847. proc Mf::setnames {name} {
  1848.     global MFfullfilename MFdirfilename MFtailfilename #
  1849.     global MFbasefilename MFextfilename MFoutputfolder #
  1850.     global MfmodeVars useWorkFold MfworkFolder
  1851.     
  1852.     set MFfullfilename $name
  1853.     set MFdirfilename [file dirname $name]
  1854.     set MFtailfilename [file tail $name]
  1855.     set MFbasefilename [file rootname [file tail $name]]
  1856.     set MFextfilename [file extension [file tail $name]]
  1857.     if {$MfmodeVars(useWorkFold) == 0} {
  1858.     set MFoutputfolder $MFdirfilename
  1859.     } else {
  1860.     set MFoutputfolder $MfmodeVars(MfworkFolder)
  1861.     }
  1862. }
  1863.  
  1864. proc Mf::getMfVersion {} {
  1865.     global  MfmodeVars  mfAppSig 
  1866.     if {$MfmodeVars(mfAppSig) != "CMT3"} {return}
  1867.     set sig "CMT3"
  1868.     set vers [objectProperty 'MACS' vers "obj {want:type(file), seld:$sig, form:fcrt, from:'null'()}"]
  1869.     if {[regexp {\“.* (.*)©.*\”\}$} $vers longvers numvers]} {
  1870.     return [list [string trim $longvers "\r\}"] [string trim $numvers "\r\}"]]
  1871.     } else {
  1872.     beep 
  1873.     message "Can't get version info"
  1874.     return
  1875.     }
  1876. }
  1877.  
  1878. # This proc looks in the current log file for a line indicating the name of
  1879. # the output file produced by Metafont so that we do not have to calculate
  1880. # the extension (which depends on the printer mode and the magnification)
  1881. proc Mf::findgfFile {} {
  1882.     global MFfullfilename MFdirfilename MFtailfilename #
  1883.     global MFbasefilename MFextfilename MFoutputfolder #
  1884.     global MfmodeVars mfAppSig MfworkFolder MFoutputfolder 
  1885.     global Mffolderpath mfwd mfset gffile
  1886.     switch $MfmodeVars(mfAppSig) {
  1887.     "CMT3" {     
  1888.         if {$mfset} {
  1889.         set mfwd $Mffolderpath
  1890.         } else {set mfwd $MFoutputfolder}
  1891.         if {![file exists [file join $mfwd $MFbasefilename.log]]} {
  1892.         beep 
  1893.         alertnote "Can't find file $MFbasefilename.log ; did you process $MFbasefilename.mf ?"
  1894.         return
  1895.         }
  1896.         catch {open [file join $mfwd $MFbasefilename.log]} fileId
  1897.     }
  1898.     "OzMF" {
  1899.         if {$mfset} {
  1900.         set mfwd $Mffolderpath
  1901.         } else {set mfwd [file dirname [win::Current]]}
  1902.         if {![file exists [file join $mfwd $MFbasefilename.log]]} {
  1903.         beep 
  1904.         alertnote "Can't find file $MFbasefilename.log ; did you process $MFbasefilename.mf ? Check that the \"delete_log\" flag in OzMetafont configs is set to false."
  1905.         return
  1906.         }
  1907.         catch {open [file join $mfwd $MFbasefilename.log]} fileId
  1908.     }
  1909.     }
  1910.     catch {read $fileId} textlog
  1911.     regsub -all "\n" $textlog "" textlog
  1912.     set textlog [split $textlog]
  1913.     catch {lsearch   -regexp  $textlog .*gf} indx
  1914.     if {[expr {$indx > 0}]} {
  1915.     set gffile [lindex $textlog $indx]
  1916.     set gffile  [file tail $gffile]
  1917.     return $gffile
  1918.     } else {
  1919.     alertnote "According to $MFbasefilename.log, no gf output written."
  1920.     return ""
  1921.     }
  1922. }
  1923.  
  1924. proc Mf::findmoderes {} {
  1925.     global MfmodeVars mfAppSig chosenMode
  1926.     if {$chosenMode == "proof"} {
  1927.     return [list "proof" "2602"]
  1928.     }
  1929.     if {$chosenMode == "smoke"} {
  1930.     return [list "smoke" "2602"]
  1931.     }
  1932.     if {[file exists $MfmodeVars(pathToModesMfFile) ]} {
  1933.         message "reading $MfmodeVars(pathToModesMfFile)"
  1934.         catch {open "$MfmodeVars(pathToModesMfFile)"} fileId
  1935.         catch {read $fileId} textlog
  1936.         # First we find the value of localfont
  1937.         if {$chosenMode == "localfont"} {
  1938.             regexp {localfont([^\;]*)\;} $textlog blabla localMfmode
  1939.             set localMfmode [string trim $localMfmode " :="]
  1940.         } elseif {$chosenMode == "smoke"} {
  1941.             set localMfmode $chosenMode
  1942.         } else {
  1943.             set localMfmode $MfmodeVars(mfModeForPrinter)            
  1944.         }
  1945.         # Then we find the resolution in dpi
  1946.         set start [string first "mode_def $localMfmode" $textlog]
  1947.         if {$start == -1} {
  1948.             alertnote "Unknown mode $localMfmode."
  1949.             return
  1950.         }
  1951.         set textlog [string range $textlog $start end]
  1952.         regexp {pixels_per_inch[^0-9)]*([0-9]*)} $textlog blabla resdpi
  1953.         return [list $localMfmode $resdpi]
  1954.     } else {
  1955.         alertnote "Can't find file modes.mf : set the path in the Current Mode Prefs."
  1956.         return [list "proof" "2602"]
  1957.     }
  1958. }
  1959.  
  1960. proc Mf::checkMfoutputFolder {} {
  1961.     global MfmodeVars MfworkFolder MFoutputfolder
  1962.     if {$MFoutputfolder == "" } {
  1963.     catch {get_directory -p "Select the output folder"} rootpath
  1964.     set MFoutputfolder [set rootpath]
  1965.     addArrDef MfmodeVars MfworkFolder $rootpath
  1966.     }
  1967. }
  1968.  
  1969. proc Mf::findrootnameProc {} {
  1970.     global rootname 
  1971.     set rootname [file rootname [file tail [win::Current]]]
  1972.     return
  1973. }
  1974.  
  1975. proc Mf::openMacroFile {flag name} {
  1976.     global MpmodeVars $flag
  1977.     if {[file exists $MpmodeVars($flag) ]} {
  1978.         message "opening $MpmodeVars($flag)"
  1979.         edit -r $MpmodeVars($flag) 
  1980.     } else {
  1981.         alertnote "Can't find file $name : where is it ?"
  1982.         catch {getfile "Please locate $name"}  chemin
  1983.     if {$chemin==""} {return}
  1984.         removeArrDef MpmodeVars $flag
  1985.         set $flag $chemin
  1986.         set MpmodeVars($flag) [set chemin]
  1987.         addArrDef MpmodeVars $flag $chemin
  1988.         edit -r $MpmodeVars($flag)
  1989.     }
  1990. }
  1991.  
  1992. proc Mf::openmodesmfProc {} {Mf::openMacroFile "pathToModesMfFile" "modes.mf"}
  1993.  
  1994. proc Mf::openplainmfProc {} {Mf::openMacroFile "pathToPlainMfFile" "plain.mf"}
  1995.  
  1996. proc Mf::deleteallfilesProc {ext} { 
  1997.     global MfmodeVars MfworkFolder MFcurrentdir MFoutputfolder
  1998.     switch $MfmodeVars(mfAppSig) {
  1999.     "CMT3" {
  2000.         if {$MFcurrentdir == ""} {
  2001.         set MFcurrentdir $MFoutputfolder
  2002.         }
  2003.     }
  2004.     "OzMF" {
  2005.         if {$MFcurrentdir == ""} {
  2006.         set MFcurrentdir [file dirname [win::Current]]
  2007.         }    
  2008.     }
  2009.     }
  2010.     if {![regexp "gf" $ext] && ![regexp "pk" $ext]} {
  2011.     set ext ".$ext"
  2012.     }
  2013.     set filesindir [glob -nocomplain -dir [file join $MFcurrentdir] *$ext]
  2014.     switch [buttonAlert "OK to remove all \"$ext\" files from $MFcurrentdir ?" "yes" "cancel" ] {
  2015.     "yes" {
  2016.         set longueur [llength $filesindir]
  2017.         if {$longueur == 0} {
  2018.         alertnote "No \"$ext\" file in output folder."
  2019.         return
  2020.         }
  2021.         foreach Mffile $filesindir {
  2022.         file delete $Mffile
  2023.         message "$longueur file(s) removed"
  2024.         }
  2025.     }
  2026.     "cancel" {return}
  2027.     }
  2028. }
  2029.  
  2030. proc Mf::allAuxfilesProc {ext} {
  2031.     global Mffolderpath
  2032.     set filesindir [glob -nocomplain -dir [file join $Mffolderpath] *.$ext]
  2033.     if {![llength $filesindir]} { 
  2034.     alertnote "No \"$ext\" files in folder $Mffolderpath"
  2035.     return
  2036.     } 
  2037.     foreach MFfile $filesindir {
  2038.     if {[file exists "$MFfile"]} {
  2039.         edit -r $MFfile
  2040.     }
  2041.     }
  2042. }
  2043.  
  2044. proc Mf::sourceFilesProc {menu item} {
  2045.     global mfPaths MfmodeVars pathToSourceFolder buildSourceFiles nestingDepth mfsymb
  2046.     if {$item == "Rebuild Source List"} {
  2047.     if {!$MfmodeVars(buildSourceFiles) || $MfmodeVars(pathToSourceFolder) == "" } {
  2048.         alertnote "You must set the \
  2049.           \"Path To Source Folder\" and check the \"Build Source Files\" checkbox in the mode preferences."
  2050.     } else {
  2051.         Mf::shadowList ""
  2052.     }
  2053.     } else {
  2054.     set upfold $menu
  2055.     eval [concat set upfold \[string trimleft $menu \"$mfsymb\"\]]
  2056.     set upfold [file join $upfold $item]
  2057.     edit $mfPaths($upfold)
  2058.     } 
  2059. }
  2060.  
  2061.  
  2062. ################################
  2063. #                              #
  2064. #   Insert commands submenus   #
  2065. #                              #
  2066. ################################
  2067.  
  2068. proc Mf::newtemplateProc {} {
  2069.     global MfmodeVars userBeginchar userEndchar
  2070.     global MfmodeVars myName myEMail myWebPage
  2071.     new -n "newfont.mf"
  2072.     #     Ask how many chars in the font
  2073.     beep
  2074.     catch {prompt "How many chars in the new font ?" 128} nbchr
  2075.     if {$nbchr == "cancel"} {
  2076.     return
  2077.     } elseif {![is::PositiveInteger $nbchr]} {
  2078.     beep
  2079.     message "invalid input: please enter a positive integer"
  2080.     return
  2081.     }
  2082.     if {$MfmodeVars(myName)=="" & $MfmodeVars(myEMail)=="" & $MfmodeVars(myWebPage)=="http://"} {
  2083.     alertnote "You should declare your name, e-mail address and Web page in the Mode Prefs to have them automatically inserted in the preambule."
  2084.     }
  2085.     goto 0
  2086.     #     Preambule instruction
  2087.     set t "\% This file : •\n"
  2088.     append t "\% Created : [Mf::creationdate]\n"    
  2089.     append t "\% Author : $MfmodeVars(myName)\n"    
  2090.     append t "\% e-mail : <$MfmodeVars(myEMail)>\n"    
  2091.     append t "\% Web-page : <$MfmodeVars(myWebPage)>\n"    
  2092.     append t "\% Comments : •\n% \n% \n% \n\n"    
  2093.     append t "font_size  •pt\#;    \% the \"design size\" of this font\n\n"
  2094.     append t "mode_setup;"
  2095.     append t "\n\n\%\%\%\% Parameters \%\%\%\%\n\n"
  2096.     append t "\n\n\%\%\%\% Pixellisation \%\%\%\%\n\n"
  2097.     append t "define_pixels(•);\n"
  2098.     append t "define_whole_pixels(•);\n"
  2099.     append t "define_whole_vertical_pixels(•);\n"
  2100.     append t "define_blacker_pixels(•);\n"
  2101.     append t "define_good_x_pixels(•);\n"
  2102.     append t "define_good_y_pixels(•);\n"
  2103.     append t "define_corrected_pixels(•);\n"
  2104.     append t "define_horizontal_corrected_pixels(•);\n"
  2105.     append t "\n\n\%\%\%\% Macros and definitions \%\%\%\%\n\n"
  2106.     append t "\n\n\%\%\%\% Drawing instructions for the characters \%\%\%\%\n\n"
  2107.     insertText $t
  2108.     set i 0
  2109.     for {set i 0} {$i < $nbchr} {incr i} {
  2110.     insertText "$MfmodeVars(userBeginchar)([set i],•,•,•);\"•\";\n\n\n\n$MfmodeVars(userEndchar);\n\n"
  2111.     }
  2112.     #     Postambule instruction
  2113.     set t "\n\n\%\%\%\% Ligtables and kerning \%\%\%\%\n\n"
  2114.     append t "ligtable \"•\": \"•\" kern • \#;\n"
  2115.     append t "\n\n\%\%\%\% General Font Parameters \%\%\%\%\n\n"    
  2116.     append t "font_slant:=• ;\t\t\t\% slant per point\n"
  2117.     append t "font_normal_space:=• ;\t\t\% interword spacing\n"
  2118.     append t "font_normal_stretch:=• ;\t\% stretchability of interword spacing\n"
  2119.     append t "font_normal_shrink:=•;\t\t\% shrinkability of interword spacing\n"
  2120.     append t "font_x_height:=• ;\t\t\% TeX's ex unit\n"
  2121.     append t "font_quad:=• ;\t\t\t\% TeX's em unit\n"
  2122.     append t "font_extra_space:=• ;\t\t\% additional spacing between sentences\n"
  2123.     append t "\nfont_coding_scheme:= \"•\";\t\% coding scheme (optional)\n"
  2124.     append t "font_identifier:= \"•\";\t\t\% family (optional)\n"
  2125.     append t "\n\nbye"
  2126.     insertText $t
  2127.     goto 0
  2128. }
  2129.  
  2130. proc Mf::creationdate {} {
  2131.     set date [lindex [mtime [now] long] 0]
  2132.     append date " - [lindex [mtime [now] long] 1]"
  2133.     return $date    
  2134. }
  2135.  
  2136. proc Mf::variablesProc {menu item} {
  2137.     switch $item {    
  2138.     " boolean" {insertObject "boolean ••;\n••"}
  2139.     " numeric" {insertObject "numeric ••;\n••"}
  2140.     " pair" {insertObject "pair ••;\n••"}
  2141.     " path" {insertObject "path ••;\n••"}
  2142.     " pen" {insertObject "pen ••;\n••"}
  2143.     " picture" {insertObject "picture ••;\n••"}
  2144.     " string" {insertObject "string ••;\n••"}
  2145.     " transform" {insertObject "transform ••;\n••"}
  2146.     " newinternal" {insertObject "newinternal ••;\n••"}
  2147.     }
  2148. }
  2149.  
  2150. proc Mf::booleanProc {menu item} {
  2151.     switch $item {    
  2152.     " charexists" {insertObject "charexists "}
  2153.     " cycle" {insertObject "cycle "}
  2154.     " false" {insertObject "false "}
  2155.     " known" {insertObject "known "}
  2156.     " true" {insertObject "true "}
  2157.     " unknown" {insertObject "unknown "}
  2158.     }
  2159. }
  2160.  
  2161. proc Mf::functionsProc {menu item} {
  2162.     switch $item {    
  2163.     " angle" {insertObject "angle ••;\n••"}
  2164.     " ceilling" {insertObject "ceilling ••;\n••"}
  2165.     " floor" {insertObject "floor(••)••"}
  2166.     " cosd" {insertObject "cosd(••)••"}
  2167.     " sind" {insertObject "sind(••)••"}
  2168.     " mexp" {insertObject "mexp(••)••"}
  2169.     " mlog" {insertObject "mlog(••)••"}
  2170.     " sqrt" {insertObject "sqrt(••)••"}
  2171.     " dotprod" {insertObject "dotprod •• = ••;\n••"}
  2172.     " eps" {insertObject "eps "}
  2173.     " epsilon" {insertObject "epsilon "}
  2174.     " infinity" {insertObject "infinity "}
  2175.     " round" {insertObject "round(••)••"}
  2176.     " hround" {insertObject "hround(••)••"}
  2177.     " vround" {insertObject "vround(••)••"}
  2178.     " solve" {insertObject "solve ••(••,••);\n••"}
  2179.     " tolerance" {insertObject "tolerance:= ••;\n••"}
  2180.     " normaldeviate" {insertObject "normaldeviate(••)••"}
  2181.     " randomseed" {insertObject "randomseed:= ••;\n••"}
  2182.     " uniformdeviate" {insertObject "uniformdeviate(••)••"}
  2183.     " whatever" {insertObject "whatever "}
  2184.     }
  2185. }
  2186.  
  2187. proc Mf::positioningProc {menu item} {
  2188.     switch $item {    
  2189.     " clearxy" {insertObject "clearxy ••;\n••"}
  2190.     " direction" {insertObject "direction •• of ••"}
  2191.     " directionpoint" {insertObject "directionpoint •• of ••"}
  2192.     " directiontime" {insertObject "directiontime •• of ••;\n••"}
  2193.     " penoffset" {insertObject "penoffset •• of ••"}
  2194.     " point…of" {insertObject "point •• of ••"}
  2195.     " precontrol…of" {insertObject "precontrol •• of ••"}
  2196.     " postcontrol…of" {insertObject "postcontrol •• of ••"}
  2197.     " intersectionpoint" {insertObject " •• intersectionpoint ••"}
  2198.     " intersectiontimes" {insertObject "•• intersectiontimes ••"}
  2199.     " good.bot" {insertObject "good.bot "}
  2200.     " good.lft" {insertObject "good.lft "}
  2201.     " good.rt" {insertObject "good.rt "}
  2202.     " good.top" {insertObject "good.top "}
  2203.     " good.x" {insertObject "good.x "}
  2204.     " good.y" {insertObject "good.y "}
  2205.     " xpart" {insertObject "xpart(••)••"}
  2206.     " xxpart" {insertObject "xxpart(••)••"}
  2207.     " xypart" {insertObject "xypart(••)••"}
  2208.     " ypart" {insertObject "ypart(••)••"}
  2209.     " yxpart" {insertObject "yxpar(••)••"}
  2210.     " yypart" {insertObject "yypart(••)••"}
  2211.     }
  2212. }
  2213.  
  2214. proc Mf::pathsProc {menu item} {
  2215.     switch $item {    
  2216.     " penstroke" {insertObject "penstroke ••;\n••"}
  2217.     " build…penstroke" {Mf::penstrokeProc}
  2218.     " flex" {Mf::mkflexProc}
  2219.     " fullcircle" {insertObject "fullcircle "}
  2220.     " halfcircle" {insertObject "halfcircle "}
  2221.     " quartercircle" {insertObject "quartercircle "}
  2222.     " superellipse" {insertObject "superellipse(••,••,••,••,••);\n••"}
  2223.     " unitsquare" {insertObject "unitsquare "}
  2224.     " makepath" {insertObject "makepath ••;\n••"}
  2225.     " interpath" {insertObject "interpath(••,••,••);\n••"}
  2226.     " subpath" {insertObject "subpath(••,••) of ••"}
  2227.     " tensepath" {insertObject "tensepath "}
  2228.     " counterclockwise" {insertObject "counterclockwise "}
  2229.     " reverse" {insertObject "reverse "}
  2230.     " turningnumber" {insertObject "turningnumber "}
  2231.     }
  2232. }
  2233.  
  2234. proc Mf::pensProc {menu item} {
  2235.     switch $item {    
  2236.     " clear_pen_memory" {insertObject "clear_pen_memory;"}
  2237.     " clearpen" {insertObject "clearpen;"}
  2238.     " currentpen" {insertObject "currentpen "}
  2239.     " makepen" {insertObject "makepen "}
  2240.     " nullpen" {insertObject "nullpen;"}
  2241.     " savepen" {insertObject "••:=savepen;••"}
  2242.     " pencircle" {insertObject "pencircle "}
  2243.     " pickup…pencircle" {insertObject "pickup pencircle "}
  2244.     " pencircle…scaled" {insertObject "pencircle •• xscaled •• yscaled ••;\n••"}
  2245.     " pickup…pencircle…scaled" {insertObject "pickup pencircle •• xscaled •• yscaled ••;\n••"}
  2246.     " pensquare" {insertObject "pensquare "}
  2247.     " pickup…pensquare" {insertObject "pickup pensquare "}
  2248.     " pensquare…scaled" {insertObject "pensquare •• xscaled •• yscaled ••;\n••"}
  2249.     " pickup…pensquare…scaled" {insertObject "pickup pensquare •• xscaled •• yscaled ••;\n••"}
  2250.     " penrazor" {insertObject "penrazor;"}
  2251.     " penspeck" {insertObject "penspeck;"}
  2252.     " penpos" {insertObject "penpos••(••,••);\n••"}
  2253.     " pen_bot" {insertObject "pen_bot"}
  2254.     " pen_lft" {insertObject "pen_lft"}
  2255.     " pen_rt" {insertObject "pen_rt"}
  2256.     " pen_top" {insertObject "pen_top"}
  2257.     " pickup" {insertObject "pickup "}
  2258.     }
  2259. }
  2260.  
  2261. proc Mf::picturesProc {menu item} {
  2262.     switch $item {    
  2263.     " blankpicture" {insertObject "blankpicture"}
  2264.     " clearit" {insertObject "clearit ••;\n••"}
  2265.     " currentpicture" {insertObject "currentpicture"}
  2266.     " nullpicture" {insertObject "nullpicture"}
  2267.     " totalweight" {insertObject "totalweight "}
  2268.     " unitpixel" {insertObject "unitpixel"}
  2269.     }
  2270. }
  2271.  
  2272. proc Mf::stringsProc {menu item} {
  2273.     switch $item {    
  2274.     " ditto" {insertObject "ditto"}
  2275.     " jobname" {insertObject "jobname"}
  2276.     " readstring" {insertObject "••:=readstring;••"}
  2277.     " substring" {insertObject "substring(••,••) of ••"}
  2278.     }
  2279. }
  2280.  
  2281. proc Mf::transformationsProc {menu item} {
  2282.     switch $item {    
  2283.     " currenttransform" {insertObject "currenttransform "}
  2284.     " identity" {insertObject "identity "}
  2285.     " inverse" {insertObject "inverse "}
  2286.     " reflectedabout" {insertObject "reflectedabout(••,••) ••"}
  2287.     " rotated" {insertObject "rotated "}
  2288.     " rotatedaround" {insertObject "rotatedaround(••,••) ••"}
  2289.     " scaled" {insertObject "scaled "}
  2290.     " shifted" {insertObject "shifted "}
  2291.     " slanted" {insertObject "slanted "}
  2292.     " transformed" {insertObject "transformed "}
  2293.     " xscaled" {insertObject "xscaled "}
  2294.     " yscaled" {insertObject "yscaled "}
  2295.     " zscaled" {insertObject "zscaled "}
  2296.     }
  2297. }
  2298.  
  2299. proc Mf::definitionsProc {menu item} {
  2300.     switch $item {    
  2301.     " def…enddef" {insertObject "def ••=\n••\nenddef;\n••"}
  2302.     " suffix" {insertObject "(suffix ••)••"}
  2303.     " expr" {insertObject "(expr ••)••"}
  2304.     " text" {insertObject "(text ••)••"}
  2305.     " primarydef…enddef" {insertObject "primarydef ••=\n••\nenddef;\n••"}
  2306.     " secondarydef…enddef" {insertObject "secondarydef ••=\n••\nenddef;\n••"}
  2307.     " tertiarydef…enddef" {insertObject "tertiarydef ••=\n••\nenddef;\n••"}
  2308.     " vardef…enddef" {insertObject "vardef ••=\n••\nenddef;\n••"}
  2309.     " begingroup…endgroup" {insertObject "begingroup ••\n\nendgroup;\n••"}
  2310.     }
  2311. }
  2312.  
  2313. proc Mf::conditionsProc {menu item} {
  2314.     switch $item {    
  2315.     " for…endfor" {insertObject "for •• : •• endfor;\n••"}
  2316.     " forever…endfor" {insertObject "forever •• endfor;\n••"}
  2317.     " forsuffixes…endfor" {insertObject "forsuffixes •• : •• endfor;\n••"}
  2318.     " if…fi" {insertObject "if •• : •• fi\n••"}
  2319.     " if…elseif…else…fi" {insertObject "if •• elseif •• else •• fi\n••"}
  2320.     " downto" {insertObject "downto "}
  2321.     " upto" {insertObject "upto "}
  2322.     " step…until" {insertObject "step •• until •• : ••"}
  2323.     " exitif" {insertObject "exitif ••;"}
  2324.     " exitunless" {insertObject "exitunless ••;"}
  2325.     }
  2326. }
  2327.  
  2328. proc Mf::drawingProc {menu item} {
  2329.     switch $item {    
  2330.     " addto…also" {insertObject "addto •• also ••;\n••"}
  2331.     " addto…currentpicture" {insertObject "addto currentpicture also currentpicture;\n••"}
  2332.     " addto…contour" {insertObject "addto •• contour •• ;\n••"}
  2333.     " addto…contour…withpen" {insertObject "addto •• contour •• withpen ••;\n••"}
  2334.     " addto…contour…withweight" {insertObject "addto •• contour •• withweight ••;\n••"}
  2335.     " addto…doublepath" {insertObject "addto •• doublepath ••;\n••"}
  2336.     " addto…doublepath…withpen" {insertObject "addto •• doublepath •• withpen ••;\n••"}
  2337.     " addto…doublepath…withweight" {insertObject "addto •• doublepath •• withweight ••;\n••"}
  2338.     " cull…dropping" {insertObject "cull •• dropping (••,••);\n••"}
  2339.     " cull…dropping…withweight" {insertObject "cull •• dropping (••,••) withweight ••;\n••"}
  2340.     " cull…keeping" {insertObject "cull •• keeping (••,••);\n••"}
  2341.     " cull…keeping…withweight" {insertObject "cull •• keeping (••,••) withweight ••;\n••"}
  2342.     " cullit" {insertObject "cullit ••;\n••"}
  2343.     " cutdraw" {insertObject "cutdraw "}
  2344.     " cutoff" {insertObject "cutoff(••,••);\n••"}
  2345.     " draw" {insertObject "draw "}
  2346.     " drawdot" {insertObject "drawdot ••;\n••"}
  2347.     " erase" {insertObject "erase ••;\n••"}
  2348.     " fill" {insertObject "fill ••;\n••"}
  2349.     " filldraw" {insertObject "filldraw ••;\n••"}
  2350.     " undraw" {insertObject "undraw "}
  2351.     " undrawdot" {insertObject "undrawdot ••;\n••"}
  2352.     " unfill" {insertObject "unfill ••;\n••"}
  2353.     " unfilldraw" {insertObject "unfilldraw ••;\n••"}
  2354.     }
  2355. }
  2356.  
  2357. proc Mf::charactersProc {menu item} {
  2358.     global MfmodeVars userBeginchar userEndchar
  2359.     switch $item {    
  2360.     " beginchar…endchar" {insertObject "$MfmodeVars(userBeginchar)(\"••\",••,••,••);\"••\";\n••\n$MfmodeVars(userEndchar);\n••"}
  2361.     " extra_beginchar" {insertObject "extra_beginchar:=\" •• \";\n••"}
  2362.     " extra_endchar" {insertObject "extra_endchar:=\" •• \";\n••"}
  2363.     }
  2364. }
  2365.  
  2366. proc Mf::unitsProc {menu item} {
  2367.     switch $item {    
  2368.     " blacker" {insertObject "blacker:=••;\n••"}
  2369.     " fillin" {insertObject "fillin:=••;\n••"}
  2370.     " o_correction" {insertObject "o_correction:= ••;\n••"}
  2371.     " fix_units" {insertObject "fix_units;\n"}
  2372.     " mode_setup" {insertObject "mode_setup;\n"}
  2373.     " pixels_per_inchs" {insertObject "pixels_per_inchs:=••;\n••"}
  2374.     " aspect_ratio" {insertObject "aspect_ratio:=••;\n••"}
  2375.     }
  2376. }
  2377.  
  2378. proc Mf::pixellisationProc {menu item} {
  2379.     switch $item {    
  2380.     " define_pixels" {insertObject "define_pixels(••);\n••"}
  2381.     " define_blacker_pixels" {insertObject "define_blacker_pixels(••);\n••"}
  2382.     " define_good_x_pixels" {insertObject "define_good_x_pixels(••);\n••"}
  2383.     " define_good_y_pixels" {insertObject "define_good_y_pixels(••);\n••"}
  2384.     " define_corrected_pixels" {insertObject "define_corrected_pixels(••);\n••"}
  2385.     " define_horizontal_corrected_pixels" {insertObject "define_horizontal_corrected_pixels(••);\n••"}
  2386.     " define_whole_pixels" {insertObject "define_whole_pixels(••);\n••"}
  2387.     " define_whole_blacker_pixels" {insertObject "define_whole_blacker_pixels(••);\n••"}
  2388.     " define_whole_vertical_pixels" {insertObject "define_whole_vertical_pixels(••);\n••"}
  2389.     " define_whole_vertical_blacker_pixels" {insertObject "define_whole_vertical_blacker_pixels(••);\n••"}
  2390.     }
  2391. }
  2392.  
  2393. proc Mf::fontInternalsProc {menu item} {
  2394.     switch $item {    
  2395.     " charlist" {insertObject "charlist ••: •• : •• : •• : ••"}
  2396.     " extensible" {insertObject "extensible ••: ••, ••, ••, ••"}
  2397.     " font_coding_scheme" {insertObject "font_coding_scheme:= \"••\";\n••"}
  2398.     " font_extra_space" {insertObject "font_extra_space:= ••;\n••"}
  2399.     " font_identifier" {insertObject "font_identifier:= \"••\";\n••"}
  2400.     " font_normal_shrink" {insertObject "font_normal_shrink:= ••;\n••"}
  2401.     " font_normal_space" {insertObject "font_normal_space:= ••;\n••"}
  2402.     " font_normal_stretch" {insertObject "font_normal_stretch:= ••;\n••"}
  2403.     " font_quad" {insertObject "font_quad:= ••;\n••"}
  2404.     " font_size" {insertObject "font_size:= ••;\n••"}
  2405.     " font_slant" {insertObject "font_slant:= ••;\n••"}
  2406.     " font_x_height" {insertObject "font_x_height:= ••;\n••"}
  2407.     " fontdimen" {insertObject "fontdimen ••: ••, ••, ••, ••\n••"}
  2408.     " headerbytes" {insertObject "headerbytes ••: ••, ••, ••, ••"}
  2409.     " ligtable" {insertObject "ligtable \"••\" : \"••\" =: oct\"••\";\n••"}
  2410.     " kern" {insertObject "kern ••\#••"}
  2411.     }
  2412. }
  2413.  
  2414. proc Mf::displayingProc {menu item} {
  2415.     switch $item {    
  2416.     " currentwindow" {insertObject "currentwindow:= ••;\n••"}
  2417.     " display…inwindow" {insertObject "display •• inwindow ••;\n••"}
  2418.     " openwindow…from…to…at" {insertObject "openwindow •• from (••,••) to (••,••) at (••,••);\n••"}
  2419.     " screen_cols" {insertObject "screen_cols:= ••;\n••"}
  2420.     " screen_rows" {insertObject "screen_rows:= ••;\n••"}
  2421.     " screenrule" {insertObject "screenrule(••,••);\n••"}
  2422.     }
  2423. }
  2424.  
  2425. proc Mf::outputProc {menu item} {
  2426.     switch $item {    
  2427.     " openit" {insertObject "openit;\n"}
  2428.     " shipit" {insertObject "shipit;\n"}
  2429.     " showit" {insertObject "showit;\n"}
  2430.     " labels" {insertObject "labels(••);\n••"}
  2431.     " labels…range…thru" {insertObject "labels(range •• thru ••);\n••"}
  2432.     " penlabels" {insertObject "penlabels(••);\n••"}
  2433.     " makelabel" {insertObject "makelabel(\"••\",••);\n••"}
  2434.     " makegrid..." {Mf::mkgridProc}
  2435.     " proofoffset" {insertObject "proofoffset(••,••);\n••"}
  2436.     " proofrule" {insertObject "proofrule(••,••);\n••"}
  2437.     " proofrulethickness" {insertObject "proofrulethickness:=••;\n••"}
  2438.     " grayfont" {insertObject "grayfont \"••\";\n••"}
  2439.     " labelfont" {insertObject "labelfont \"••\";\n••"}
  2440.     " slantfont" {insertObject "slantfont \"••\";\n••"}
  2441.     " titlefont" {insertObject "titlefont \"••\";\n••"}
  2442.     }
  2443. }
  2444.  
  2445. proc Mf::debuggingProc {menu item} {
  2446.     switch $item {    
  2447.     " errhelp" {insertObject "errhelp "}
  2448.     " errmessage" {insertObject "errmessage \"••\";\n••"}
  2449.     " message" {insertObject "message \"••\";\n••"}
  2450.     " stop" {insertObject "stop;\n"}
  2451.     " show" {insertObject "show ••;\n••"}
  2452.     " showdependencies" {insertObject "showdependencies;\n"}
  2453.     " showstats" {insertObject "showstats;\n"}
  2454.     " showtoken" {insertObject "showtoken ••;\n••"}
  2455.     " showvariable" {insertObject "showvariable ••;\n••"}
  2456.     " loggingall" {insertObject "loggingall:= ••\n••"}
  2457.     " tracingall" {insertObject "tracingall;\n"}
  2458.     " tracingnone" {insertObject "tracingnone;\n"}
  2459.     " batchmode" {insertObject "batchmode;\n"}
  2460.     " errorstopmode" {insertObject "errorstopmode;\n"}
  2461.     " nonstopmode" {insertObject "nonstopmode;\n"}
  2462.     " scrollmode" {insertObject "scrollmode;\n"}
  2463.     }
  2464. }
  2465.  
  2466. proc Mf::miscProc {menu item} {
  2467.     switch $item {    
  2468.     " capsule_def" {insertObject "capsule_def ••;\n••"}
  2469.     " expandafter" {insertObject "expandafter "}
  2470.     " gobble" {insertObject "gobble "}
  2471.     " gobbled" {insertObject "gobbled "}
  2472.     " interact" {insertObject "interact;\n••"}
  2473.     " numtok" {insertObject "numtok "}
  2474.     " scantokens" {insertObject "scantokens "}
  2475.     " special" {insertObject "special \" ••\";\n••"}
  2476.     " numspecial" {insertObject "numspecial ••;\n••"}
  2477.     }
  2478. }
  2479.  
  2480. proc Mf::varintProc {menu item} {
  2481.     switch $item {    
  2482.     " autorounding" {insertObject "autorounding:= ••;\n••"}
  2483.     " designsize" {insertObject "designsize:= ••;\n••"}
  2484.     " fontmaking" {insertObject "fontmaking:= ••;\n••"}
  2485.     " granularity" {insertObject "granularity:= ••;\n••"}
  2486.     " pausing" {insertObject "pausing:= ••;\n••"}
  2487.     " proofing" {insertObject "proofing:= ••;\n••"}
  2488.     " showstopping" {insertObject "showstopping:= ••;\n••"}
  2489.     " smoothing" {insertObject "smoothing:= ••;\n••"}
  2490.     " charcode" {insertObject "charcode:= ••;\n••"}
  2491.     " chardp" {insertObject "chardp:= ••;\n••"}
  2492.     " chardx" {insertObject "chardx:= ••;\n••"}
  2493.     " chardy" {insertObject "chardy:= ••;\n••"}
  2494.     " charext" {insertObject "charext:= ••;\n••"}
  2495.     " charht" {insertObject "charht:= ••;\n••"}
  2496.     " charic" {insertObject "charic:= ••;\n••"}
  2497.     " charwd" {insertObject "charwd:= ••;\n••"}
  2498.     " hppp" {insertObject "hppp:= ••;\n••"}
  2499.     " vppp" {insertObject "vppp:= ••;\n••"}
  2500.     " xoffset" {insertObject "xoffset:= ••;\n••"}
  2501.     " yoffset" {insertObject "yoffset:= ••;\n••"}
  2502.     " day" {insertObject "day;"}
  2503.     " month" {insertObject "month;"}
  2504.     " year" {insertObject "year;"}
  2505.     " time" {insertObject "time;"}
  2506.     " tracingcapsules" {insertObject "tracingcapsules:= ••;\n••"}
  2507.     " tracingchoices" {insertObject "tracingchoices:= ••;\n••"}
  2508.     " tracingcommands" {insertObject "tracingcommands:= ••;\n••"}
  2509.     " tracingedges" {insertObject "tracingedges:= ••;\n••"}
  2510.     " tracingequations" {insertObject "tracingequations:= ••;\n••"}
  2511.     " tracingmacros" {insertObject "tracingmacros:= ••;\n••"}
  2512.     " tracingonline" {insertObject "tracingonline:= ••;\n••"}
  2513.     " tracingoutput" {insertObject "tracingoutput:= ••;\n••"}
  2514.     " tracingpens" {insertObject "tracingpens:= ••;\n••"}
  2515.     " tracingrestores" {insertObject "tracingrestores:= ••;\n••"}
  2516.     " tracingspecs" {insertObject "tracingspecs:= ••;\n••"}
  2517.     " tracingstats" {insertObject "tracingstats:= ••;\n••"}
  2518.     " tracingtitles" {insertObject "tracingtitles:= ••;\n••"}
  2519.     " turningcheck" {insertObject "turningcheck:= ••;\n••"}
  2520.     " warningcheck" {insertObject "warningcheck:= ••;\n••"}
  2521.     }
  2522. }
  2523.  
  2524. # In this proc, choose the number of horizontal and vertical lines in a grid
  2525. proc Mf::mkgridProc {} {
  2526.     set macroName "makegrid"
  2527.     beep
  2528.     catch {prompt "$macroName:  how many x-coordinates ?" 3} numbx
  2529.     if {$numbx == "cancel"} {
  2530.     return
  2531.     } elseif {![is::PositiveInteger $numbx]} {
  2532.     beep
  2533.     message "invalid input: please enter a positive integer"
  2534.     return
  2535.     }
  2536.     catch {prompt "$macroName:  how many y-coordinates ?" 3} numby
  2537.     if {$numby == "cancel"} {
  2538.     return
  2539.     } elseif {![is::PositiveInteger $numby]} {
  2540.     beep
  2541.     message "invalid input: please enter a positive integer"
  2542.     return
  2543.     }
  2544.     if {$numbx && $numby} {
  2545.     set body "makegrid(••"
  2546.     for {set i 1} {$i < $numbx} {incr i} {
  2547.         append body ",••"
  2548.     }
  2549.     append body ")(••"
  2550.     for {set i 1} {$i < $numby} {incr i} {
  2551.         append body ",••"
  2552.     }
  2553.     append body ");\n••"
  2554.     } else {
  2555.     set body "••\r"
  2556.     }
  2557.     insertObject $body
  2558. }
  2559.  
  2560. # In this proc, choose the number of points on a flex path
  2561. proc Mf::mkflexProc {} {
  2562.     set macroName "flex"
  2563.     beep
  2564.     catch {prompt "$macroName:  how many points on the flex-path ?" 3} numbp
  2565.     if {$numbp == "cancel"} {
  2566.     return
  2567.     } elseif {![is::PositiveInteger $numbp]} {
  2568.     beep
  2569.     message "invalid input: please enter a positive integer"
  2570.     return
  2571.     }
  2572.     if {$numbp} {
  2573.     set body "flex(••"
  2574.     for {set i 1} {$i < $numbp} {incr i} {
  2575.         append body ",••"
  2576.     }
  2577.     append body ") ••"
  2578.     } else {
  2579.     set body "••\r"
  2580.     }
  2581.     insertObject $body
  2582. }
  2583.  
  2584. # In this proc, choose the number of points on a penstroke
  2585. proc Mf::penstrokeProc {} {
  2586.     set macroName "penstroke"
  2587.     beep
  2588.     catch {prompt "$macroName:  how many points on the penstroke ?" 3} numbp
  2589.     if {$numbp == "cancel"} {
  2590.     return
  2591.     } elseif {![is::PositiveInteger $numbp]} {
  2592.     beep
  2593.     message "invalid input: please enter a positive integer"
  2594.     return
  2595.     }
  2596.     if {$numbp} {
  2597.     set body "penstroke z1e"
  2598.     for {set i 2} {$i < [expr {$numbp + 1}]} {incr i} {
  2599.         append body "..z${i}e"
  2600.     }
  2601.     append body " ;"
  2602.     } else {
  2603.     set body "••\r"
  2604.     }
  2605.     insertObject $body
  2606. }
  2607.  
  2608.  
  2609. #############################
  2610. #                           #
  2611. #   Mode specific goodies   #
  2612. #                           #
  2613. #############################
  2614.  
  2615. #########   Syntax Coloring  ###########
  2616. # We define two groups of keywords :
  2617. # -  the macros of the Metafont plain format. Default color : blue
  2618. # -  the Metafont primitives. Default color : magenta
  2619. # These colors can be modified in the mode prefs : see "Keyword Color" 
  2620. # and "Primitives Color".
  2621.  
  2622. set mfKeyWords { 
  2623. abs beginchar blacker blankpicture bot bye byte capsule_def ceilling 
  2624. change_width checksum clear_pen_memory clearit clearpen 
  2625. clearxy codingscheme counterclockwise cullit currentpen currentpicture 
  2626. currenttransform currentwindow cutdraw cutoff decr define_blacker_pixels 
  2627. define_good_x_pixels define_good_y_pixels define_pixels define_whole_pixels 
  2628. direction directionpoint displaying ditto dotprod downto draw drawdot endchar 
  2629. eps epsilon erase exitunless extra_beginchar extra_endchar extraspace face 
  2630. family fill filldraw fix_units flex font_coding_scheme font_extra_space 
  2631. font_identifier font_normal_shrink font_normal_space font_normal_stretch 
  2632. font_quad font_size font_slant font_x_height fontdimen fullcircle gfcorners gobble 
  2633. gobbled good.bot good.lft good.rt good.top good.x good.y grayfont halfcircle 
  2634. hide hround identity imagerules incr infinity interact interpath intersectionpoint 
  2635. inverse italcorr join_radius label labelfont labels lft loggingall makegrid 
  2636. makelabel max min mod mode_setup nextlarger nodisplays notransforms numtok 
  2637. o_correction of openit openwindow or pen_bot pen_lft pen_rt pen_top penlabels 
  2638. penpos penrazor penspeck pensquare penstroke pickup pixels_per_inchs proofoffset 
  2639. proofrule proofrulethickness quad quartercircle range reflectedabout relax rep 
  2640. rotatedaround round rt savepen screen_cols screen_rows screenchars screenrule 
  2641. screenstrokes secondary shipit showit shrink slant slantfont solve space stop 
  2642. stretch superellipse tensepath text thru titlefont tolerance top tracingall 
  2643. tracingnone undraw undrawdot unfill unfilldraw unitpixel unitsquare upto 
  2644. varchar vround whatever xheight 
  2645. }
  2646.  
  2647. regModeKeywords  -e {%} -c $MfmodeVars(commentColor) \
  2648.   -k $MfmodeVars(keywordColor)  -s $MfmodeVars(stringColor) Mf $mfKeyWords
  2649. unset mfKeyWords
  2650.  
  2651. set mfprimKeyWords { 
  2652. ASCII addto also and angle at atleast autorounding batchmode
  2653. begingroup boolean char character charcode chardp chardx chardy charexists
  2654. charext charht charic charlist charwd comment contour controls cosd cull curl
  2655. cycle day decimal def delimiters designsize designunits directiontime
  2656. display doublepath dump dropping else elseif end enddef endfor
  2657. endgroup endinput errhelp errmessage errorstopmode everyjob exitif
  2658. expandafter expr extensible false fi fillin floor fontdimen fontmaking
  2659. fontname fontdsize fontat forever forsuffixes from granularity
  2660. headerbytes hex hppp if inner input interim intersectiontimes inwindow
  2661. jobname keeping kern known krn length let lig ligtable makepath
  2662. makepen map mapfont message mexp mlog month newinternal nonstopmode
  2663. normaldeviate not nullpen nullpicture numeric numspecial oct odd
  2664. openwindow outer pair parameter path pausing pen pencircle penoffset picture
  2665. point postcontrol precontrol primary primarydef proofing quote
  2666. randomseed readstring reverse rotated save scaled scantokens
  2667. scrollmode secondarydef setchar shifted shipout show showdependencies
  2668. showstats showstopping showtoken showvariable sind slanted smoothing
  2669. special sqrt step str string subpath substring suffix tension tertiary
  2670. tertiarydef time to totalweight tracingcapsules tracingchoices
  2671. tracingcommands tracingedges tracingequations tracingmacros
  2672. tracingonline tracingoutput tracingpens tracingrestores tracingspecs
  2673. tracingstats tracingtitles transform transformed true turningcheck
  2674. turningnumber uniformdeviate unknown until vardef vppp warningcheck
  2675. withpen withweight xoffset xpart xscaled xxpart xypart year yoffset
  2676. ypart yscaled yxpart yypart zscaled 
  2677. }
  2678.  
  2679. regModeKeywords  -a -k $MfmodeVars(primitivesColor) Mf $mfprimKeyWords
  2680.  
  2681. # We store the primitives in a list which will be used below by the Mf::DblClick proc.
  2682. set Mfprimlist [split $mfprimKeyWords]
  2683. # We don't need mfprimKeyWords anymore :
  2684. unset mfprimKeyWords
  2685.  
  2686.  
  2687. ############   Completions  ################
  2688.  
  2689. set completions(Mf) {contraction Input completion::cmd completion::electric}
  2690.  
  2691. set Mfcmds { addto also angle ASCII atleast autorounding batchmode beginchar
  2692. begingroup blacker blankpicture boolean byte capsule_def ceilling
  2693. change_width char character charcode chardp chardx chardy charexists
  2694. charext charht charic charlist charwd checksum clearit clearpen clearxy
  2695. clear_pen_memory codingscheme comment contour controls cosd
  2696. counterclockwise cull cullit curl currentpen currentpicture
  2697. currenttransform currentwindow cutdraw cutoff cycle decimal decr
  2698. define_blacker_pixels define_good_x_pixels define_good_y_pixels
  2699. define_pixels define_whole_pixels delimiters designsize direction
  2700. directionpoint directiontime display displaying ditto dotprod doublepath
  2701. downto draw drawdot dropping dump else elseif endchar enddef endfor
  2702. endgroup endinput epsilon erase errhelp errmessage errorstopmode everyjob
  2703. exitif exitunless expandafter expr extensible extraspace extra_beginchar
  2704. extra_endchar face false family fill filldraw fillin fix_units flex floor
  2705. fontdimen fontmaking font_coding_scheme font_extra_space font_identifier
  2706. font_normal_shrink font_normal_space font_normal_stretch font_quad
  2707. font_size font_slant font_x_height forever forsuffixes from fullcircle
  2708. gfcorners gobble gobbled good.bot good.lft good.rt good.top good.x good.y
  2709. granularity grayfont halfcircle headerbytes hide hppp hround identity
  2710. imagerules incr infinity inner input interact interim interpath
  2711. intersectionpoint intersectiontimes inverse inwindow italcorr jobname
  2712. join_radius keeping kern known label labelfont labels length ligtable
  2713. loggingall makegrid makelabel makepath makepen message mexp mlog mode_setup
  2714. month newinternal nextlarger nodisplays nonstopmode normaldeviate
  2715. notransforms nullpen nullpicture numeric numspecial numtok openit
  2716. openwindow outer o_correction pair path pausing pencircle
  2717. penlabels penoffset penpos penrazor penspeck pensquare penstroke pen_bot
  2718. pen_lft pen_rt pen_top pickup picture pixels_per_inchs point postcontrol
  2719. precontrol primary primarydef proofing proofoffset proofrule
  2720. proofrulethickness quad quartercircle quote randomseed range readstring
  2721. reflectedabout relax reverse rotated rotatedaround round save savepen
  2722. scaled scantokens screenchars screenrule screenstrokes screen_cols
  2723. screen_rows scrollmode secondary secondarydef shifted shipit shipout show
  2724. showdependencies showit showstats showstopping showtoken showvariable
  2725. shrink sind slant slanted slantfont smoothing solve space special sqrt step
  2726. stop stretch string subpath substring suffix superellipse tensepath tension
  2727. tertiary tertiarydef text thru time titlefont tolerance totalweight
  2728. tracingall tracingcapsules tracingchoices tracingcommands tracingedges
  2729. tracingequations tracingmacros tracingnone tracingonline tracingoutput
  2730. tracingpens tracingrestores tracingspecs tracingstats tracingtitles
  2731. transform transformed true turningcheck turningnumber undraw undrawdot
  2732. unfill unfilldraw uniformdeviate unitpixel unitsquare unknown until upto
  2733. varchar vardef vppp vround warningcheck whatever withpen withweight xheight
  2734. xoffset xpart xscaled xxpart xypart year yoffset ypart yscaled yxpart
  2735. yypart zscaled 
  2736. }
  2737.     
  2738. # # # # # Abbreviations # # # # #
  2739. set Mfelectrics(bc)   "◊kill0$MfmodeVars(userBeginchar)(\"••\",••,••,••);\"••\";\n••\n\n$MfmodeVars(userEndchar);\n••"
  2740. set Mfelectrics(bg)   "◊kill0begingroup ••\n\nendgroup;\n••"
  2741. set Mfelectrics(dp) "◊kill0define_pixels(••);\n••"
  2742. set Mfelectrics(dbp) "◊kill0define_blacker_pixels(••);\n••"
  2743. set Mfelectrics(dcp) "◊kill0define_corrected_pixels(••);\n••"
  2744. set Mfelectrics(dgxp) "◊kill0define_good_x_pixels(••);\n••"
  2745. set Mfelectrics(dgyp) "◊kill0define_good_y_pixels(••);\n••"
  2746. set Mfelectrics(dhcp) "◊kill0define_horizontal_corrected_pixels(••);\n••"
  2747. set Mfelectrics(dwp) "◊kill0define_whole_pixels(••);\n••"
  2748. set Mfelectrics(dwvp) "◊kill0define_whole_vertical_pixels(••);\n••"
  2749. set Mfelectrics(dwvb) "◊kill0define_whole_vertical_blacker_pixels(••);\n••"
  2750. set Mfelectrics(sc) "◊kill0screen_cols:= ••;"
  2751. set Mfelectrics(sr) "◊kill0screen_rows:= ••;"
  2752. set Mfelectrics(xpa) "◊kill0expandafter "
  2753.  
  2754. set Mfelectrics(for)  " •• : •• endfor;\n••"
  2755. set Mfelectrics(def)   " ••=\n••\nenddef;\n••"
  2756. set Mfelectrics(prim)   "◊kill0primarydef ••=\n••\nenddef;\n••"
  2757. set Mfelectrics(sec)   "◊kill0secondarydef ••=\n••\nenddef;\n••"
  2758. set Mfelectrics(ter)   "◊kill0tertiarydef ••=\n••\nenddef;\n••"
  2759. set Mfelectrics(vardef)   " ••=\n••\nenddef;\n••"
  2760. set Mfelectrics(forever)   " •• endfor;\n••"
  2761. set Mfelectrics(forsuf)   " •• : •• endfor;\n••"
  2762. set Mfelectrics(if)   " •• : •• fi\n••"
  2763.  
  2764. # # # # # contractions # # # # #
  2765. set Mfelectrics(cu'n) "◊kill0currentpen "
  2766. set Mfelectrics(cu'p) "◊kill0currentpicture "
  2767. set Mfelectrics(cu't) "◊kill0currenttransform "
  2768. set Mfelectrics(cu'w) "◊kill0currentwindow "
  2769. set Mfelectrics(di'p) "◊kill0directionpoint "
  2770. set Mfelectrics(di't) "◊kill0directiontime "
  2771. set Mfelectrics(re'a) "◊kill0reflectedabout(••,••) ••"
  2772. set Mfelectrics(ro'a) "◊kill0rotatedaround(••,••) ••"
  2773.  
  2774. # Proc to complete the 'input' instructions. Type 'input  xx'  and  the  proc
  2775. # will look for a known mf file  whose  name  starts  with  'xx'.  This  proc
  2776. # searches among the mf files in the source directory  defined  in  the  mode
  2777. # prefs (and in ALL its subfolders). If  the  source  directory  hasn't  been
  2778. # defined, it searches in the current folder and its subfolders.
  2779. proc Mf::Completion::Input {dummy} {
  2780.     global MFfilenames 
  2781.     global mfSubmenuItems MfmodeVars pathToSourceFolder buildSourceFiles nestingDepth
  2782.     if {!$MfmodeVars(buildSourceFiles)} {
  2783.     set MFfilenames {}
  2784.     Mf::listSrcInDir [file dirname [win::Current]] mf
  2785.     }
  2786.     set MFfilenames [join $MFfilenames]
  2787.     regsub -all "  " $MFfilenames " " MFfilenames
  2788.     set cmd [completion::lastTwoWords begin]
  2789.     if { [string trim $begin] != "input" } { return 0 }
  2790.     completion::Find $cmd [completion::fromList $cmd MFfilenames]
  2791. }    
  2792.  
  2793.  
  2794. ############   Key Bindings  ################
  2795.  
  2796. # We define Metafont specific key bindings : all of them
  2797. # use 'ctrl-m' followed by a letter.
  2798. # Key bindings to choose the processing mode :
  2799. #    hit ctrl-m and then one of the letters p, s, l or u to select
  2800. #    respectively proof, smoke, localfont or user defined modes.
  2801. Bind 'm' <z> prefixChar Mf
  2802. Bind 'p' <M> {Mf::choosemodeProc "metafontMode" "proof"} Mf
  2803. Bind 's' <M> {Mf::choosemodeProc "metafontMode" "smoke"} Mf
  2804. Bind 'l' <M> {Mf::choosemodeProc "metafontMode" "localfont"} Mf
  2805. Bind 'u' <M> {Mf::choosemodeProc "metafontMode" "userDefined"} Mf
  2806. # Now key bindings to process the <b>uffer, a <f>ile or a <d>irectory :
  2807. # 'ctrl-m b', 'ctrl-m f' and 'ctrl-m d' respectively.
  2808. Bind 'b' <M> {Mf::menuProc "Metafont" "runTheBuffer"}
  2809. Bind 'f' <M> {Mf::menuProc "Metafont" "runAFile"}
  2810. Bind 'd' <M> {Mf::runafolderProc}
  2811. # A key binding ('ctrl-m n') to create a new font template :
  2812. Bind 'n' <M> {Mf::newtemplateProc} Mf
  2813. # A key binding ('ctrl-m m') to edit the <m>odes file modes.mf :
  2814. Bind 'm' <M> {Mf::openmodesmfProc} Mf
  2815. # A key binding ('ctrl-m c') to edit the macro <c>ommands file plain.mf :
  2816. Bind 'c' <M> {Mf::openplainmfProc} Mf
  2817. # A key binding ('ctrl-m g') to edit the log file :
  2818. Bind 'g' <M> {Mf::setnames [win::Current] ; Mf::editlogProc} Mf
  2819. # A key binding ('ctrl-m t') to convert <t>fm file to pl :
  2820. Bind 't' <M> {Mf::setnames [win::Current];Mf::doplProc;set prefixplf "";menu::buildSome otherFiles;Mf::editplProc} Mf
  2821. # A key binding ('ctrl-m i') to convert gf file to dv<i> :
  2822. Bind 'i' <M> {Mf::otherfilesProc "otherFiles" "convertGfToDvi"} Mf
  2823. # A key binding ('ctrl-m k') to convert gf file to p<k> :
  2824. Bind 'k' <M> {Mf::otherfilesProc "otherFiles" "convertGfToPk"} Mf
  2825. # A key binding ('ctrl-m v') to <v>iew the d<v>i :
  2826. Bind 'v' <M> {Mf::setnames [win::Current];Mf::viewdviProc} Mf
  2827.  
  2828.  
  2829.  
  2830. ##########    File Marking   ############
  2831.  
  2832. ##########    The "M" menu   ############
  2833. # Marking is different in mf source files and in pl or vpl files.
  2834. # # # In mf source files :
  2835. # The 'def' and 'vardef' definitions are marked in the "M" menu (top right of
  2836. # the current window). All the 'beginchar/endchar' groups will be marked too.
  2837. # Even if you changed the name of these  'beginchar'  routines  in  the  mode
  2838. # specific prefs : for instance, if you chose to call them "myfontchar"  then
  2839. # all the "myfontchar" instructions will be marked.
  2840. # For a 'beginchar' instruction, the proc looks if there is a string  at  the
  2841. # end of the line (usually describing the char being designed) : if yes  mark
  2842. # this string, if not then mark the 'beginchar' and its character code.
  2843. # # # In property list files :
  2844. # the LIGTABLE and FONTDIMEN arrays are marked as  well  as  every  character
  2845. # dimensions data.
  2846.  
  2847. proc Mf::MarkFile {} {
  2848.     global MfmodeVars
  2849.     global MFextfilename
  2850.     Mf::setnames [win::Current]
  2851.     if {$MFextfilename == ".mf"} {
  2852.     set bgnchar $MfmodeVars(userBeginchar)
  2853.     #  First mark the defs and vardefs
  2854.     set end [maxPos]
  2855.     set pos [minPos]
  2856.     while {![catch {search -f 1 -r 1 -m 0 -i 0 "^def \[ _\\w\]*|^vardef \[ _\\w\]*" $pos} res]} {
  2857.         set start [lindex $res 0]
  2858.         set end [lindex $res 1]
  2859.         set txt [getText [pos::math $start - 1] $end]
  2860.         set pos [nextLineStart $start]
  2861.         set inds($txt) [lineStart [pos::math $start - 1]]
  2862.     }
  2863.     if {[info exists inds]} {
  2864.         foreach f [lsort [array names inds]] {
  2865.         set next [nextLineStart $inds($f)]
  2866.         setNamedMark $f $inds($f) $next $next
  2867.         }
  2868.         unset inds
  2869.     }
  2870.     
  2871.     #  Then mark the 'beginchar' instructions
  2872.     set end [maxPos]
  2873.     set pos [minPos]
  2874.     while {![catch {eval [concat search -f 1 -r 1 -m 0 -i 0\
  2875.       [list "^$bgnchar.*$"] $pos]} res]} {
  2876.         set start [lindex $res 0]
  2877.         set end [lindex $res 1]
  2878.         set txt [getText [pos::math $start - 1] $end]
  2879.         if {[regexp "$bgnchar" $txt]} {
  2880.         if {![regexp {; ?\".*\" ?;} $txt txt]} {
  2881.             regexp "$bgnchar\[ _\\w\\d\\\(\\\"\]*" $txt txt 
  2882.             set txt "$txt)"
  2883.         } else {
  2884.             set txt [string trim $txt ";\""]
  2885.         }
  2886.         }
  2887.         set pos [nextLineStart $start]
  2888.         set inds($txt) [lineStart [pos::math $start - 1]]
  2889.     }
  2890.     if {[info exists inds]} {
  2891.         foreach f [lsort [array names inds]] {
  2892.         set next [nextLineStart $inds($f)]
  2893.         setNamedMark $f $inds($f) $next $next
  2894.         }
  2895.     }
  2896.     } else {
  2897.     set pos [minPos]
  2898.     set end [maxPos]
  2899.     while {![catch {search -f 1 -r 1 -m 0 -i 0 {^[\(](FONTDIMEN|LIGTABLE)} $pos} res]} {
  2900.         set start [lindex $res 0]
  2901.         set end [lindex $res 1]
  2902.         set txt [getText [pos::math $start +1] $end]
  2903.         set pos [nextLineStart $start]
  2904.         set inds($txt) [lineStart [pos::math $start - 1]]
  2905.     }
  2906.     
  2907.     if {[info exists inds]} {
  2908.         foreach f  [array names inds] {
  2909.         set next [nextLineStart $inds($f)]
  2910.         setNamedMark $f $inds($f) $next $next
  2911.         }
  2912.     }
  2913.     
  2914.     set pos [minPos]
  2915.     set end [maxPos]
  2916.     while {![catch {search -f 1 -r 1 -m 0 -i 0 {^[\(]CHARACTER[ \w\d]*} $pos} res]} {
  2917.         set start [lindex $res 0]
  2918.         set end [lindex $res 1]
  2919.         set txt [getText [pos::math $start +1] $end]
  2920.         set pos [nextLineStart $start]
  2921.         set inds($txt) [lineStart [pos::math $start - 1]]
  2922.     }
  2923.     
  2924.     if {[info exists inds]} {
  2925.         foreach f [lsort -increasing [array names inds]] {
  2926.         set next [nextLineStart $inds($f)]
  2927.         setNamedMark $f $inds($f) $next $next
  2928.         }
  2929.     }
  2930.     }
  2931. }
  2932.  
  2933.  
  2934. ##########    The "{}" menu   ############
  2935. # The "{}" pop-up menu contains the functions defined in a  source  file.  We
  2936. # list here all the def and vardef definitions as well  as  the  files  input
  2937. # with an "input"  command.  Here  we  'lappend'  twice  on  purpose  because
  2938. # ::parseFuncs general proc takes one out of two :
  2939. proc Mf::parseFuncs {} {
  2940.     global funcExpr Mfparse
  2941.     set Mfparse 1
  2942.     set pos [minPos]
  2943.     set m {}
  2944.     while {[set res [search -s -f 1 -r 1 -i 0 -n "$funcExpr" $pos]] != ""} {
  2945.     lappend m [eval getText $res]
  2946.     lappend m [eval getText $res]
  2947.     set pos [lindex $res 1]
  2948.     }
  2949.     if {[expr {[lsearch -regexp $m "^(def|primarydef|secondarydef|tertiarydef) "] > -1}]} {lappend m "DEF :" ; lappend m "DEF :"}
  2950.     if {[expr {[lsearch -regexp $m "^vardef "] > -1}]} {lappend m "VARDEF :" ; lappend m "VARDEF :"}
  2951.     set m [lsort -ignore $m]
  2952.     set f [lsort -ignore [Mf::findInputFiles]]
  2953.     if {[llength $f]} {
  2954.     set f [linsert $f 0 "INPUT FILES : " "INPUT FILES : "]
  2955.     set m [linsert $m 0 "(-" "(-"]
  2956.     }
  2957.     return [concat $f $m]
  2958. }
  2959.  
  2960. proc Mf::findInputFiles {} {
  2961.     global Mfparse
  2962.     set files {}
  2963.     set pos [minPos]
  2964.     while {[set res [search -s -f 1 -r 1 -i 0 -n {^.*input.+$} $pos]] != ""} {
  2965.     set txt [eval getText $res]
  2966.     if {![regexp {^\%} $txt]} {
  2967.         regsub -all "(^.*input +)" $txt "" txt
  2968.         regsub -all " .+" $txt "" txt
  2969.         lappend files $txt
  2970.         if {$Mfparse} {lappend files $txt}
  2971.     } 
  2972.     set pos [lindex $res 1]
  2973.     }
  2974.     set Mfparse 0
  2975.     return $files
  2976. }
  2977.  
  2978.  
  2979. ##########   Double-click   ############
  2980. # If you Command-Double-Click on a keyword you access  its  definition.  This
  2981. # proc looks first for a definition in the current file itself, then  in  the
  2982. # list of primitives, then in the plain Metafont macros file and  finally  in
  2983. # the other text files located in the same folder and called in  the  current
  2984. # file by an input command (typically they are macros files).
  2985.  
  2986. set Mfinternals [list "blacker" "currentwindow" "displaying" "eps" "epsilon" \
  2987.   "infinity" "join_radius" "number_of_modes" "o_correction" "pair" "path" "pen_bot"\
  2988.   "pen_lft" "pen_rt" "pen_top" "pixels_per_inch" "screen_cols" "screen_rows" "tolerance" ]
  2989.  
  2990. # set Mfconstants [list "basename" "base_version" "blankpicture" "currentpen"\
  2991. #  "currentpen_path" "currenttransform" "ditto" "extra_beginchar" "extra_endchar"\
  2992. #  "extra_setup" "fullcircle" "halfcircle" "identity" "mode_name" "penspeck"\
  2993. #  "quartercircle" "rulepen" "unitpixel" "unitsquare" ]
  2994.  
  2995. proc Mf::DblClick {from to} {
  2996.     global MfmodeVars pathToPlainMfFile Mfprimlist Mfparse Mfinternals 
  2997. #     global Mfconstants
  2998.     select $from $to
  2999.     set word [getText $from $to]
  3000.     set Mfparse 0
  3001.     # First we look for the word's definition in the current file :
  3002.     set pos [minPos]
  3003.     if {![catch {eval [concat search -f 1 -r 1 -m 1 -i 0\
  3004.       [list "\(var|primary|secondary|tertiary\)?def\[ \\w\]+$word"] $pos]} res]} {
  3005.     goto [lineStart [lindex $res 0]]
  3006.     select [lindex $res 0] [lindex $res 1]
  3007.     return
  3008.     }
  3009.     # If search failed, check if it is a Metafont primitive.
  3010.     if {[expr {[lsearch -exact $Mfprimlist "$word"] > -1}]} {
  3011.     alertnote "\"$word\" is a Metafont primitive.\rSee the MetafontBook."
  3012.     return
  3013.     }
  3014.     # If search failed, check if it is a 'newinternal'.
  3015.     if {[expr {[lsearch -exact $Mfinternals "$word"] > -1}]} {
  3016.     alertnote "\"$word\" is a constant of type \"newinternal\".\rSee the MetafontBook or Metapost User's Manual."
  3017.     return
  3018.     }
  3019.     # If search failed, look in the plain.mf macros file. Its path must
  3020.     # have been defined in the mode prefs.
  3021.     set f $MfmodeVars(pathToPlainMfFile)
  3022.     if {![file exists $f]} {
  3023.     alertnote "Can't find file plain.mf : where is it ?"
  3024.     catch {getfile "Find file plain.mf"} chemin
  3025.     if {$chemin == ""} {return}
  3026.     removeArrDef MfmodeVars pathToPlainMfFile
  3027.     set pathToPlainMfFile $chemin
  3028.     set MfmodeVars(pathToPlainMfFile) [set chemin]
  3029.     addArrDef MfmodeVars pathToPlainMfFile $chemin
  3030.     }    
  3031.     set cid [scancontext create]
  3032.     set searchstri "(var|primary|secondary|tertiary)?def\[ \\w\]+$word\[^\\w\]+"
  3033.     set searchstrii "(path|pen|picture|string|transform)\[ ,\\w\]+$word"
  3034.     scanmatch -- $cid $searchstri {set matches($f) 1}
  3035.     scanmatch -- $cid $searchstrii {set matches($f) 1}
  3036.     if {![catch {set fid [open $f]}]} {
  3037.     message "Looking at '[file tail $f]'"
  3038.     scanfile $cid $fid
  3039.     close $fid
  3040.     }
  3041.     if {[info exists matches]} {
  3042.     Mf::BringOrEdit $MfmodeVars(pathToPlainMfFile) -r
  3043.     goto $matchInfo(offset)
  3044.     set res [search -s -f 1 -r 0 -i 0 -m 1 -n $word $matchInfo(offset)]
  3045.     select $matchInfo(offset)] [lindex $res 1]
  3046.     unset matches
  3047.     return
  3048.     }
  3049.     # As a last resort, we search all the input files found in the source file provided
  3050.     # they are located in the same folder as the current file.
  3051.     set f [Mf::findInputFiles]
  3052.     if {[llength $f]} {
  3053.     foreach filetail $f {
  3054.         set filetail [string trim $filetail ".mf"]
  3055.         set fullname [file join [file dirname [win::Current]] $filetail.mf]
  3056.         if {[file exists $fullname]} {
  3057.         if {![catch {set fid [open $fullname]}]} {
  3058.             message "Looking at '$filetail'"
  3059.             scanfile $cid $fid
  3060.             close $fid
  3061.         }
  3062.         } 
  3063.         if {[info exists matches]} {
  3064.         Mf::BringOrEdit $fullname -r
  3065.         goto $matchInfo(offset)
  3066.         set res [search -s -f 1 -r 0 -i 0 -n $word $matchInfo(offset)]
  3067.         select $matchInfo(offset) [lindex $res 1]
  3068.         return
  3069.         }    
  3070.     }
  3071.     }    
  3072.     scancontext delete $cid
  3073.     beep
  3074.     message "Could'nt find a definition for \"$word\"."
  3075. }
  3076.  
  3077.  
  3078. ##########   Option-click on title bar   ############
  3079. # If you Option-Click on a the title bar, you get a list of all  the  mf  and
  3080. # log files located :
  3081. # - in the "local" folder (folder of currentwindow). 
  3082. # - in the "selected" folder (selected when you process an entire folder with
  3083. # "Run A Folder" or in the "Remove Files" sub menu)
  3084. # Selecting any item will open it in a window or bring its window to front if
  3085. # it is already open.
  3086.  
  3087. proc Mf::OptionTitlebar {} {
  3088.     global MFcurrentdir sep minItemsInTitlePopup
  3089.     set minItemsInTitlePopup 1
  3090.     set sep "-"
  3091.     set filesinlocaldir [glob -nocomplain -dir [file dirname [win::Current]] *.mf]
  3092.     set logsinlocaldir [glob -nocomplain -dir [file dirname [win::Current]] *.log]
  3093.     set filesinselecteddir {}
  3094.     set logsinselecteddir {}
  3095.     if {$MFcurrentdir !="" && $MFcurrentdir!=[file dirname [win::Current]]} {
  3096.     set filesinselecteddir [glob -nocomplain -dir $MFcurrentdir *.mf]
  3097.     set logsinselecteddir [glob -nocomplain -dir $MFcurrentdir *.log]
  3098.     }
  3099.     set l {}
  3100.     foreach f  $filesinlocaldir {
  3101.     lappend l [file tail $f]
  3102.     }
  3103.     foreach dir [list filesinselecteddir logsinlocaldir logsinselecteddir] {
  3104.     eval [concat "if \{\[llength \$$dir\]\} \{lappend l \$sep ; \
  3105.       foreach f \$$dir \{lappend l \[file tail \$f\]\}\}"]      
  3106.     }
  3107.     return $l
  3108. }
  3109.  
  3110. proc Mf::OptionTitlebarSelect {item} {
  3111.     global MFcurrentdir sep
  3112.     if {$item == $sep} {return}
  3113.     if {[file exists [file join [file dirname [win::Current]] $item]]} {
  3114.     Mf::BringOrEdit [file join [file dirname [win::Current]] $item] -c
  3115.     } else {
  3116.     Mf::BringOrEdit [file join $MFcurrentdir $item] -c
  3117.     }
  3118. }
  3119.  
  3120. proc Mf::BringOrEdit {name {type ""}} {
  3121.     catch {lsearch -exact [winNames] [file tail $name]} indx
  3122.     if {[expr {$indx > -1}]} {
  3123.     bringToFront [file tail $name]
  3124.     } else {
  3125.     edit $type $name
  3126.     }
  3127. }
  3128.  
  3129.  
  3130.  
  3131.  
  3132. # Send comments to :
  3133. # <berdesg@easynet.fr>